matlab计算三角波频谱

2025-01-24 13:27:50
推荐回答(1个)
回答1:

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