Re: problem with calculating period with FFT




Hi Ehsan:

You may want to expand the code a bit, as follows:

% Sampling Rate:
Fs = 500; % Hertz
dt = 1/Fs; % seconds

% Time Domain:
StartTime = -1; % seconds
StopTime = 1; % seconds
t = StartTime:dt:StopTime-dt; % seconds

% Frequency domain:
N = length(t);
df = Fs/N; % Hertz
f = -Fs/2:df:Fs/2-df; % Hertz

% Carrier Frequency:
Fc = 10; % Hertz

% Signal:
x = cos(2*pi*Fc*t);

% Spectrum:
X = fftshift(fft(fftshift(x)));


% Plotting:

figure;

subplot(2,1,1);
plot(t,x);
grid on;
xlabel('time (seconds)');
title('Time Domain');

subplot(2,1,2);
plot(f,abs(X));
grid on;
xlabel('frequency (hertz)');
title('Frequency Domain');


Notice that the plot of the spectrum in the Frequency Domain shows two
impulses at -10 Hz and +10 Hz, as you would expect for a pure cosine wave
with carrier Fc = 10 Hz.

I hope that helps.

Thanks.

Rick



"ehsan mirrahimi" <ehsan.mirrahimi@xxxxxxxxxxxxx> wrote in message
news:fdm4l5$38$1@xxxxxxxxxxxxxxxxxxxxx
hi suppose this is my signal

t=linspace(-1,1,1000);x=cos(20*pi*t);plot(abs((fft(x))))

http://imageupload.com/out.php/i27113_fft.jpg

the sampling frequency is:1000/2=500Hz
the maximum FFT value indext is 981
so what is the period of the signal?
can anyone help me?



.



Relevant Pages

  • Re: method for digital filtering
    ... not saying the sampling rate increases as a function of the load ... your coordinate system may not be time you may have a uniform coordinate ... Why do I get the IR If I high pass filter the signal? ... I have zeroes in the frequency domain of the input ...
    (comp.dsp)
  • Fourier Transform and Sampling rate jitter
    ... "Fourier Transform" transform the time domain data into frequency domain ... information on the premise that the sampling rate is constant or in some ... If the sampling clock jitter, ...
    (comp.dsp)