how to plot frequecy spectrum of fft ?
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(3 个)
Youssef Khmou
2013-3-10
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 个评论
Ketan Dewan
2016-9-28
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spectral Measurements 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!