Re: problem with calculating period with FFT
- From: "Rick Rosson" <rrossoNO@xxxxxxxxxxxxxxxx>
- Date: Sat, 29 Sep 2007 17:26:29 -0400
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?
.
- Follow-Ups:
- Re: problem with calculating period with FFT
- From: ehsan mirrahimi
- Re: problem with calculating period with FFT
- References:
- problem with calculating period with FFT
- From: ehsan mirrahimi
- problem with calculating period with FFT
- Prev by Date: Re: Plot to a figure from a function
- Next by Date: Embedded MATLAB Function in Simulink
- Previous by thread: problem with calculating period with FFT
- Next by thread: Re: problem with calculating period with FFT
- Index(es):
Relevant Pages
|