Take the fft of a rectangular pulse
2 views (last 30 days)
Show older comments
I am trying to plot the fft of a rectangular pulse 'x(t)' and I know that the answer should be a sinc function however that is not what my plot looks like. Perhaps I made an error in my code
clear,clc
ts=10e-3;
t=-2:ts:2;
x=heaviside(t+1)-heaviside(t-1);
fmax=1/ts;
fs=1/4;
freq=0:fs:(fmax);
figure(1)
plot(t,x)
axis([-2 2 -1.5 1.5])
grid 'on'
figure(2)
X=fft(x)/length(x);
plot(freq,X)
0 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!