DSPRelated.com
Forums

FFT : How to plot...

Started by umer_farooque78 October 23, 2006
I want some help regarding the plotting of the FFT in matlab...Here is
the code :

Fs=650; %
Ts=1/Fs; %
N=2000; % number of samples wanted, vector length
%( better N=Fs; or N=Fs*2 or N=Fs/2...) why ????
Fo=1/(Ts*N) % frequency resolution
Fx=fft(x); % DFT of x
Nx=length(x); %
Fo= 1/(Ts*Nx);
f=0:Fo:Fs-Fo; % frequency vector from 0 ((N-1)/N) 2 pi = 0 Fs-Fo
plot(f(1:Nx/2),abs(Fx(1:N/2))) % we plot only the first halves of f
and Fx. 0-Fs/2
title('Frequency domain Plot of x')
xlabel('f [ Hz ]')
ylabel('Amplitude')
Now , what is this frequency resolution vector .Is there any special
mathematics in taking the frequency vector for plotting the FFT...plz
help me ...

Your fourth line is correct, that should be your resolution equation. Now, if you want N 00 points just use fft(x,N). The signal is zero padded if length(x) < N and truncated if greater. Be careful, you're missing pi if N is odd (not your case though). To plot, just use f = [0 : N/2 - 1]*(Fs/N). Note that the last product term is your resolution (what you have).

umer_farooque78 wrote: I want some help regarding the plotting of the FFT in matlab...Here is
the code :

Fse0; %
Ts=1/Fs; %
N 00; % number of samples wanted, vector length
%( better N=Fs; or N=Fs*2 or N=Fs/2...) why ????
Fo=1/(Ts*N) % frequency resolution
Fxt(x); % DFT of x
Nx=length(x); %
Fo= 1/(Ts*Nx);
f=0:Fo:Fs-Fo; % frequency vector from 0 ((N-1)/N) 2 pi = 0 Fs-Fo
plot(f(1:Nx/2),abs(Fx(1:N/2))) % we plot only the first halves of f
and Fx. 0-Fs/2
title('Frequency domain Plot of x')
xlabel('f [ Hz ]')
ylabel('Amplitude')
Now , what is this frequency resolution vector .Is there any special
mathematics in taking the frequency vector for plotting the FFT...plz
help me ...