Home > Archive > Matlab > April 2005 > Re: Frequency spectrum using FFT
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Re: Frequency spectrum using FFT
|
|
| Markus Geigl 2005-04-23, 3:59 pm |
| Hi,
by increasing the length of the FFT you get better resolution in the
frequency domain.
Regards,
Markus
Try this and you should be able to see the two frequency bins:
tf=100;
Sample_Rate=100; %Hz
dt=1/Sample_Rate;
t1=0:dt:tf;
y1=sin(0.6*t1)+cos(1.2*t1); % f1=0.6/(2*pi)=0.0955
% f2=1.2/(2*pi)=0.1910
magY = abs(fft(y1)/length(y1)); % length of FFT is now length(y1), so
% radix2-algorithm does not apply ...
freq = Sample_Rate*(0:length(y1)-1)/length(y1);
plot(freq(1:round(end/2)),magY(1:round(end/2)));
"Sandeep" <sandeepagarwal79@yahoo.com> schrieb im Newsbeitrag
news:ef03beb.-1@webx.raydaftYaTP...
> Hi,
> I am trying to obtain frequency spectrum using fft. The input signal
> is a combination of two different frequencies, 0.6 and 1.2. The
> procedure followed is same as in references (Matlab). However, I am
> not able to see both frequencies in the spectrum.
>
> tf=100;
> Sample_Rate=100; %Hz
>
> dt=1/Sample_Rate;
>
> t1=0:dt:tf;
> y1=sin(0.6*t1)+cos(1.2*t1)
>
> Y = fft(y1,512);
> Pyy =Y.* conj(Y) / 512;
> Pyy=Pyy';
> freq = Sample_Rate*(0:256)/512;
>
> plot(freq,Pyy(1:257));
| |
| Steve Amphlett 2005-04-23, 3:59 pm |
| Markus Geigl wrote:
>
>
> Hi,
>
> by increasing the length of the FFT you get better resolution in
> the
> frequency domain.
Specifically, if your blocksize is of length: T, your resolution is
1/T. I.e., your first spectral line is DC and your second is 1/T,
your third at 2/T etc.
| |
| sandeep 2005-04-23, 8:58 pm |
| Thanks Markus and Steve,
I have one more question. The periodic function of which I am trying
to obtain frequency content is actually generated by ODE. Since the
time step is not constant, I am using INTERFT to interpolate the data
to constant time step. However, when I look at the new data closely,
its actually changing the frequency of the signal slightly. Even
including large no of points, it still remains the same. Is there
anything that can be done?
Thanks
Steve Amphlett wrote:
>
>
> Markus Geigl wrote:
in[color=darkred]
>
> Specifically, if your blocksize is of length: T, your resolution is
> 1/T. I.e., your first spectral line is DC and your second is 1/T,
> your third at 2/T etc.
|
|
|
|
|