Effacer les filtres
Effacer les filtres

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

2 vues (au cours des 30 derniers jours)
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.

Réponse acceptée

Dr. Seis
Dr. Seis le 20 Mai 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 commentaires
Dr. Seis
Dr. Seis le 20 Mai 2013
Modifié(e) : Dr. Seis le 20 Mai 2013
Your tau is a very small number... the smaller tau is the faster your exponential function will fall to zero. The way you have it set up, your sample interval is much, much too big. Between the first and second time sample, your time function has already fallen to (pretty much) zero. So you need to make your T a lot smaller (i.e., 1/(2*10^9)). But when you do this, you will see that your tau is actually quite big for the frequency f0 of your sine wave (it takes many 100s of oscillations before you begin to notice any changes in the amplitude of the sine wave). My suggestion is to be mindful of tau (controls the amplitude falloff), T (controls the interval between time samples), and f0 (center frequency of your sine wave) because these numbers will control whether you see reasonable values (when you populate x)... or no values... or garabage values.
My suggestion is to step back and look at an example of what you are trying to accomplish with values of tau, T, and f0 that are all parameterized appropriately (in a relative sense). For example try:
T = 1/200;
fs = 1 / T;
N = 512;
t = (0:N-1) * T;
tau = .1; %sec
f0=10; % 10 Hz
x = (exp(1).^( -t./(2*tau) ) ) .* sin(2*pi*f0*t);
plot(t,x);
Vera
Vera le 21 Mai 2013
thanks a lot Elige.
I will definitely step back and look more carefully at all these aspects.
:)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Fourier Analysis and Filtering dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by