连续周期三角波信号频谱图N=10;n1=-N:-1;C1=-4*j*sin(n1*pi/2)/pi^2./n1.^2;C0=0;n2=1:N;C2=-4*j*sin(n2*pi/2)/pi^2./n2.^2;Cn=[C1C0C2];n=-N:N;subplot(2,1,1);stem(n,abs(Cn));subplot(2,1,2);stem(n,angle(Cn));周期性方波频谱a=1;tao=0.1;t=0.5;n0=t/tao;n=0:2*n0;fn_p=a*tao/t*(sin(n*pi*tao/t+eps*(n==0)))./(n*pi*tao/t+eps*(n==0));fn_pabs=abs(fn_p);fn_pang=angle(fn_p);fn_mabs=fliplr(fn_pabs(2:(2*n0)+1));fn_mang=-fliplr(fn_pang(2:(2*n0)+1));fnabs=[fn_mabsfn_pabs];fnang=[fn_mangfn_pang];subplot(2,1,1);stem((-2*n0:2*n0),fnabs);text(4,0.11,'amplitudespectrum');subplot(2,1,2);stem((-2*n0:2*n0),fnang);text(-2,2,'phasespectrum');-10-8-6-4-2024681000.10.20.30.40.5-10-8-6-4-20246810-2-1012连续的锯齿波频谱图n=7;T0=2;A=2;T1=2;tn_i=1;fortn=0:0.01:T1*T0y_t(tn_i)=A*rem(tn,T0)/T0;t_t(tn_i)=tn;tn_i=tn_i+1;endt=0:0.01:T1*T0;x=A/2;pi=3.1415926;w0=2*pi/T0;fori=1:nfw(i)=i*w0;a(i)=-A/(pi*i);y(i,:)=a(i)*sin(fw(i)*t);x=x+y(i,:);end;%subplot(1,3,1);%plot(t_t,[y_t;x]);%title('¾â³Ý²¨£¬¾â³Ý²¨ºÏ³Éͼ')%subplot(1,3,2);-10-8-6-4-2024681000.050.10.150.2amplitudespectrum-10-8-6-4-20246810-4-2024phasespectrum%plot(t,[x;y]);%title('0-n´Îг²¨ºÏ³Éͼ')subplot(1,3,3);stem(fw,a);title('¾â³Ý²¨ÆµÆ×ͼ')单位阶跃信号n0=0;nf=10;ns=3;N=32;M=100;n2=n0:nf;x2=[(n2-ns)=0];subplot(3,1,1),stem(n2,x2);%»³öx2µÄµ¥Î»½×Ô¾ÐòÁÐi=0:N-1;j=0:M-1;%Ñùµã×Ô0¿ªÊ¼y1=fft(x2,N);%¶Ôx2½øÐÐ32µã¸µÀïÒ¶±ä»»y2=fft(x2,M);%¶Ôx2½øÐÐ100µã¸µÀïÒ¶±ä»»aw1=abs(y1);aw2=abs(y2);%Çó·ù¶ÈÆ×subplot(3,1,2);plot(i,aw1)%32µã¸µÀïÒ¶±ä»»µÄƵÆ×ͼsubplot(3,1,3);plot(j,aw2)02040-0.7-0.6-0.5-0.4-0.3-0.2-0.10锯齿波频谱图正弦波fs=input('pleaseinputthefs:');%É趨²ÉÑùƵÂÊN=input('pleaseinputtheN:');%É趨Êý¾Ý³¤¶Èt=0:0.001:1;f=100;%É趨ÕýÏÒÐźÅƵÂÊ%Éú³ÉÕýÏÒÐźÅx=sin(2*pi*f*t);figure(1);subplot(211);plot(t,x);%×÷ÕýÏÒÐźŵÄʱÓò²¨ÐÎaxis([0,0.1,-1,1]);title('ÕýÏÒÐźÅʱÓò²¨ÐÎ');%z=square(50*t);%subplot(212)%plot(t,z)%axis([0,1,-2,2]);%title('·½²¨ÐźÅʱÓò²¨ÐÎ');grid;%½øÐÐFFT±ä»»²¢×öƵÆ×ͼy=fft(x,N);%½øÐÐfft±ä»»mag=abs(y);%Çó·ùÖµf=(0:N-1)*fs/N;%ºá×ø±êƵÂʵıí´ïʽΪf=(0:M-1)*Fs/M;figure(2);subplot(211);01234567891000.5105101520253035051001020304050607080901000510plot(f,mag);%×öƵÆ×ͼaxis([0,1000,0,200]);title('ÕýÏÒÐźŷùƵÆ×ͼ');01002003004005006007008009001000050100150200正弦信号幅频谱图