figure(1); syms t n T; f1=4/T*t+1; f2=-4/T*t+1; a0=(int(f1,-T/2,0)+int(f2,0,T/2))/T; ya1=f1*cos(n*2*pi/T*t); ya2=f2*cos(n*2*pi/T*t); yb1=f1*sin(n*2*pi/T*t); yb2=f2*sin(n*2*pi/T*t); an=(int(ya1,-T/2,0)+int(ya2,0,T/2))/T*2; bn=(int(yb1,-T/2,0)+int(yb2,0,T/2))/T*2; %1.2锯齿波信号频谱图 cn=(an^2+bn^2)^(1/2); n=1:10; cn1=subs(cn); cn2=[0,cn1]; h=stem([0,n],cn2); hold on; plot([0,n],cn2) title('幅度频谱') xlabel('\omega'); ylabel('c_n'); %相位当an大于0是相位为0,当an小于零的时候相位为pi figure(2); syms t w; ft=exp(-3*t)*heaviside(t); subplot(2,2,1); ezplot(ft); title('时域波形f(t)=e^-^3^tu(t)'); xlabel('t'); ylabel('f(t)'); Fw=fourier(ft); w=-3:0.01:3; Fw1=subs(Fw); subplot(2,2,2); plot(w,abs(Fw1)); title('幅度谱'); xlabel('角频率(\omega)'); ylabel('幅度'); subplot(2,2,3); plot(w,angle(Fw1)*pi/180); title('相位谱'); xlabel('角频率(\omega)'); ylabel('相位\phi'); figure(3); syms t w tao; tao=3; Fw=tao*sin(tao*w/2)/(tao*w/2); ft=ifourier(Fw,t); subplot(2,2,1); ezplot(ft,[-2,2]); title('时域波形f(t)'); xlabel('t'); ylabel('f(t)'); subplot(2,2,2); ezplot(Fw,[-10,10]); title('频谱图'); xlabel('\omega'); subplot(2,2,3); ezplot(abs(Fw),[-10,10]); title('幅度谱'); xlabel('角频率(\omega)'); ylabel('幅度'); subplot(2,2,4); ezplot(angle(Fw),[-10,10]); title('相位谱'); xlabel('\omega'); ylabel('相位\phi'); figure(4); syms w t; Fw=(1-j*w)/(1+j*w); w=-5:0.01:5; Fw1=subs(Fw); subplot(2,1,1); plot(w,abs(Fw1)); title('幅度谱'); xlabel('角频率(\omega)'); ylabel('幅度|H(j\omega)|'); subplot(2,1,2); plot(w,angle(Fw1)*pi/180); xlabel('角频率(\omega)'); ylabel('相位\phi'); figure(5); syms w t; Hw=(1-j*w)/(1+j*w); ht=ifourier(Hw,t); subplot(2,2,1); ezplot(ht); title('冲激响应'); xlabel('t'); ylabel('h(t)'); ft=exp(-2*t)*heaviside(t); subplot(2,2,2); ezplot(ft); title('输入信号f(t)=e^-^2^tu(t)'); xlabel('t'); ylabel('f(t)');grid on; Fw=fourier(ft); Yw=Fw*Hw; yt=ifourier(Yw,t); subplot(2,2,3); ezplot(yt,[-1,4,-1,0.5]); title('零状态响应'); xlabel('t'); ylabel('y_f(t)');grid on; figure(6); ft=exp(-2*t)*heaviside(t); subplot(1,2,1); ezplot(ft); title('e^-^2^tu(t)'); xlabel('t'); ylabel('f(t)');grid on; Fw=fourier(ft); Yw=Fw*Hw; yt=ifourier(Yw,t); subplot(1,2,2); ezplot(yt,[-1,4,-1,0.5]); title('零状态响应'); xlabel('t'); ylabel('y_f(t)');