# how to set the sampling frequency and the time vector for an aperiodic signal while FFT and IFFT

12 views (last 30 days)
Vera on 20 May 2013
I need to plot x=e^(-t/2*tau) * sin(2*pi*f0*t) and then do the FFT, and IFFT to come back. f0=1 GHz while tau=2 micro secs While evaluating the function x, it gives me all values zero. I dont know why... I am not sure how to set the Fs (sampling frequency) and N (the length). Please help me as soon as you can. Here below some code.
T = 1/200; fs = 1 / T; %fs=150 N = 512; %t=0:T:1; t = (0:N-1) * T;
tau = 2*10^-6; %sec fo=1*10^9; % 1 GHz
x = (exp(1).^( -t./(2*tau) ) ) .* sin(2*pi*fo*t); %exp(1)=e %The DFT approximation to the CTFT is given by X_DFT = T * fft( x ); df = fs / N; f = df .* (0:(N-1)); w = 2 * pi * f; %or for a symmetric spectrum X_DFT2 = fftshift( X_DFT ); f2 = df .* ((-N/2):(N/2-1)); w2 = 2 * pi * f2; %The exact CTFT and DTFT are fa = linspace( 0 , 2 * fs , 1000 ); wa = 2 * pi * fa; fa2 = linspace( -1 * fs , 1 * fs , 1000 ); wa2 = 2 * pi * fa2; X_CTFT = 1.0 ./ ( a + 1i .* wa ); X_CTFT2 = 1.0 ./ ( a + 1i .* wa2 ); X_DTFT = T * 1.0 ./ ( 1 - exp( -1i .* wa .* T) .* exp( -a .* T ) ); X_DTFT2 = fftshift( X_DTFT );
%Plotting the asymmetric transforms
figure( 1 ); plot ( f , abs( X_DFT ) , 'r-o' ); hold on; plot( fa , abs( X_CTFT ) , 'b-' ); plot( fa , abs( X_DTFT ) , 'g-' ); xlabel( 'f (Hz)' ); ylabel( '|X(f)|' ); title( '|X(f)|' ); axis( [ 0 400 0 0.12] ); legend( 'CTFT estimated from DFT' , 'Analytic CTFT' , 'Analytic DTFT' ); hold off; print( 'ft_mag.eps' , '-depsc' );
figure(2); plot(t,x);
Thanks to all for any help you can provide to me.
##### 2 CommentsShowHide 1 older comment
Vera on 20 May 2013
thanks Jose'-Luis

Sign in to comment.

### Accepted Answer

Dr. Seis on 20 May 2013
For your second time sample [ t(2) = 0.005 ], your exponential [ exp(-0.005/(4*10^-6)) ] is equivalent to exp(-1250), which is basically 0.
##### 3 CommentsShowHide 2 older comments
Vera on 21 May 2013
thanks a lot Elige.
I will definitely step back and look more carefully at all these aspects.
:)

Sign in to comment.

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by