资源描述:
《matlab练习有程序超全.docx》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、特定冲击串卷积程序一fora=1:3kk(a)=4-a;endfora=4:7kk(a)=a-3;endfora=8:15kk(a)=0;endcloseall;subplot(2,1,1);stem(kk);subplot(2,1,2);stem(abs(fft(kk,16)))程序二n=0:15;%定义序列的长度是15a=0.1;f=0.0625;x=exp(-a*n).*sin(2*pi*f*n);closeall;subplot(2,1,1);stem(x);subplot(2,1,2);stem(abs(
2、fft(x)))程序三n=0:15;%定义序列的长度是15p=8;q=2;x=exp(-1*(n-p).^2/q);closeall;subplot(3,1,1);stem(abs(fft(x)))p=8;q=4;x=exp(-1*(n-p).^2/q);subplot(3,1,2);stem(abs(fft(x)))p=8;q=8;x=exp(-1*(n-p).^2/q);subplot(3,1,3);stem(abs(fft(x)))程序四n=1:50;%定义序列的长度是50hb=zeros(1,50);%注意
3、:MATLAB中数组下标从1开始hb(1)=1;hb(2)=2.5;hb(3)=2.5;hb(4)=1;closeall;subplot(3,1,1);stem(hb);title('系统hb[n]');m=1:50;%定义序列的长度是50A=444.128;%设置信号有关的参数a=50*sqrt(2.0)*pi;T=0.001;%采样率w0=50*sqrt(2.0)*pi;x=A*exp(-a*m*T).*sin(w0*m*T);%pi是MATLAB定义的π,信号乘可采用“.*”subplot(3,1,2);st
4、em(x);title('输入信号x[n]');y=conv(x,hb);subplot(3,1,3);stem(y);title('输出信号y[n]');k=-25:25;X=x*(exp(-j*pi/12.5)).^(n'*k);magX=abs(X);%绘制x(n)的幅度谱subplot(3,2,1);stem(magX);title('输入信号的幅度谱');angX=angle(X);%绘制x(n)的相位谱subplot(3,2,2);stem(angX);title('输入信号的相位谱')Hb=hb*(e
5、xp(-j*pi/12.5)).^(n'*k);magHb=abs(Hb);%绘制hb(n)的幅度谱subplot(3,2,3);stem(magHb);title('系统响应的幅度谱');angHb=angle(Hb);%绘制hb(n)的相位谱subplot(3,2,4);stem(angHb);title('系统响应的相位谱')n=1:99;k=1:99;Y=y*(exp(-j*pi/12.5)).^(n'*k);magY=abs(Y);%绘制y(n)的幅度谱subplot(3,2,5);stem(magY);
6、title('输出信号的幅度谱');angY=angle(Y);%绘制y(n)的相位谱subplot(3,2,6);stem(angY);title('输出信号的相位谱')程序五n=1:50;%定义序列的长度是50x=zeros(1,50);%注意:MATLAB中数组下标从1开始x(1)=1;x(2)=2.5;x(3)=2.5;x(4)=1;closeall;subplot(3,1,1);stem(x);title('单位冲击信号序列');k=-25:25;X=x*(exp(-j*pi/12.5)).^(n'*k)
7、;magX=abs(X);%绘制x(n)的幅度谱subplot(3,1,2);stem(magX);title('单位冲击信号的幅度谱');angX=angle(X);%绘制x(n)的相位谱subplot(3,1,3);stem(angX);title('单位冲击信号的相位谱')程序六n=1:50x=sign(sign(10-n)+1);closeall;subplot(3,1,1);stem(x);title('单位冲击信号序列');k=-25:25;X=x*(exp(-j*pi/25)).^(n'*k);mag
8、X=abs(X);%绘制x(n)的幅度谱subplot(3,1,2);stem(magX);title('单位冲击信号的幅度谱');angX=angle(X);%绘制x(n)的相位谱subplot(3,1,3);stem(angX);title('单位冲击信号的相位谱')程序7n=1:50;%定义序列的长度是50x=zeros(1,50);%注意:MATLA