how to plot frequecy spectrum of fft ?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
0 commentaires
Réponses (3)
Youssef Khmou
le 10 Mar 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 ?
0 commentaires
Azzi Abdelmalek
le 10 Mar 2013
t=-1:0.01:1
y=zeros(1,numel(t))
y(abs(t)<1/2)=1
Y=fft(y)
stem(abs(Y))
0 commentaires
Ketan Dewan
le 28 Sep 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 ?
0 commentaires
Voir également
Catégories
En savoir plus sur Spectral Measurements dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!