t=-2:0.01:2;y=zeros(1,401);for i=1:401y(i)=(1-abs(t(i)))*(abs(t(i))<1);endfy=abs(fft(y,256));w=100*(0:128)/256;subplot(211)plot(t,y)subplot(212)plot(w,fy(1:129))