clc;clear;close all;
tn=2^15;
t=linspace(-50 ,50,tn);
y=zeros(size(t));
y(abs(t)<2)=1;
figure
plot(t,y);
axis([-50 50 -1 2]);
grid on;
deltat=t(2)-t(1);
Y=fftshift(fft(y))*deltat;
fmin=-1/2*deltat;
fmax=1/2*deltat;
f=linspace(fmin ,fmax,tn);
figure
plot(abs(Y));
评论0