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

回答(3 个)

Youssef  Khmou
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 ?

Azzi Abdelmalek
Azzi Abdelmalek 2013-3-10
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 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 ?

类别

Help CenterFile Exchange 中查找有关 Spectral Measurements 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by