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

8 views (last 30 days)

Show older comments

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.

### Accepted Answer

Dr. Seis
on 20 May 2013

### More Answers (0)

### See Also

### Community Treasure Hunt

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

Start Hunting!