how to plot frequecy spectrum of fft ?

3 visualizaciones (últimos 30 días)
deepak kumar
deepak kumar el 10 de Mzo. de 2013
Respondida: Ketan Dewan el 28 de Sept. de 2016
i am learning fft in matlab . i am trying to plot frequency response of fft of rectangular pulse in matlab. my function is x(t)=1 , -1/2<t<1/2 i found the fft of function but i am trying to plot fft frequency plot of this function and not getting

Respuestas (3)

Youssef  Khmou
Youssef Khmou el 10 de Mzo. de 2013
hi,
To efficiently use FFT, you need to know the sampling frequency of your signal
So you can proceed like the following : 1) You construct your rectangular pulse :
Fs=100; % Sampling frequency
t=-1:1/Fs:1;
y=zeros(size(t));
% Rectangular pulse
for n=1:length(t)
if t(n)>-0.5 && t(n)<0.5
y(n)=1;
end
end
plot(t,y)
axis([-1 1 -1 2])
grid on,
2) You compute the spectrum, the instructions here are available for any given signal :
% Discrete Fourier Transform
L=length(y);
N=ceil(log2(L));
fy=fft(y,2^N)/(L/2);
f=(Fs/2^N)*(0:2^(N-1)-1);
figure, plot(f,abs(fy(1:2^(N-1))));
Theoretically, you have to know what to expect : Take a look at this page : http://demonstrations.wolfram.com/RectangularPulseAndItsFourierTransform/
Let us try to see if the numeric result matches the theory :
G=sinc(pi*f);
figure, plot(f,G);
Does it look the same ?

Azzi Abdelmalek
Azzi Abdelmalek el 10 de Mzo. de 2013
t=-1:0.01:1
y=zeros(1,numel(t))
y(abs(t)<1/2)=1
Y=fft(y)
stem(abs(Y))

Ketan Dewan
Ketan Dewan el 28 de Sept. de 2016
I have a question regarding the sampling clok for the FFT.
I am using a clock which is made of 100 samples. Should I use for the FFT the aboslute clock freqeuncy or 100* clock frequency ?

Categorías

Más información sobre Spectral Measurements en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by