t=0:0.001:6;
Y=(t>0&t<2.75)*0 + (t>=2.75&t<3.25)*10 + (t>=3.25&t<6)*0;
MyFourierT(Y);
title('矩形脉冲的频谱');function MyFourierT(x)
X=abs(fft(x));
f=(0:length(X)-1)*1000/length(X);
plot(f,X);
axis([0 200,-1,1100]);
xlabel('频率/Hz');
ylabel('振幅');
grid on
end
06-24
1942
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)