小弟就是想模仿上面这个图用matlab模拟下,程序如下
clear all;
figure(1);
t=-1:0.01:1;
y=(t>=-1 & t<=1)*1;
plot(t,y);
%以上为模拟出一个矩形脉冲信号;
figure(2);
w=-6*pi:0.01:6*pi;
Y=fft(y);
plot(w,Y);
%以上用fft画频谱,但是报错如下:
Warning: Imaginary parts of complex X and/or Y arguments ignored.
> In fft at 10
??? Error using ==> plot
Vectors must be the same lengths.
Error in ==> fft at 10
plot(w,Y);