数字信号处理实验第二次实验matlab系统的频率响应_信号系统matlab实验
数字信号处理实验第二次实验matlab系统的频率响应由刀豆文库小编整理,希望给你工作、学习、生活带来方便,猜你可能喜欢“信号系统matlab实验”。
第二次实验
第二题
x1=cos(2*pi*0.1*n);x2=cos(2*pi*0.4*n);x=a*x1+b*x2;den=1;ic=[0,0];
y=filter(num,den,x,ic);figure
y1=filter(f,g,x);stem(y1);n=0:100;
s1=cos(2*pi*0.05*n);s2=cos(2*pi*0.47*n);x=s1+s2;num=[1,-1];y=filter(num,2,x);
subplot(2,2,1)plot(n,s2)axis([0,100,-2,2])xlabel('time index n');ylabel('amplitude')title('signal s1')
subplot(2,2,2)plot(n,s1)axis([0,100,-2,2])xlabel('time index n');ylabel('amplitude')title('signal s2')
subplot(2,2,3)plot(n,x)axis([0,100,-2,2])xlabel('time index n');ylabel('amplitude')title('signal x')
subplot(2,2,4)plot(n,y)axis([0,100,-2,2])xlabel('time index n');ylabel('amplitude')title('signal y,m=2')第三题 clf;n=0:40;a=2;b=3;
num=[1,1,1]/3;den=1;ic=[1,1];
y1=filter(num,den,x1,ic);
y2=filter(num,den,x2,ic);
y=filter(num,den,x,ic);yt=a*y1+b*y2;d=y-yt;figure subplot(3,1,1);stem(n,y);
ylabel('amplitude');title('y=f(a*x1+b*x2)');
subplot(3,1,2);stem(n,yt);
ylabel('amplitude');title('y=a*f(x1)+b*f(x2)');
subplot(3,1,3);stem(n,d);
ylabel('amplitude');title('y-yt');第四题 clf;n=0:40;n1=0:50;a=2;b=3;
x1=cos(2*pi*0.1*n);x2=cos(2*pi*0.4*n);x=a*x1+b*x2;x10=[zeros(1,10)x];num=[1,1,1]/3;
y10=[zeros(1,10),y];yx10=filter(num,den,x10,ic);d=y10-yx10;close all;figuresubplot(2,2,1);stem(n,y);
ylabel('amplitude');title('y');
subplot(2,2,2);stem(n1,d);ylabel('amplitude');title('d');
subplot(2,2,3);stem(n1,y10);ylabel('amplitude');title('y10');
subplot(2,2,4);stem(n1,yx10);ylabel('amplitude');title('yx10');
第五题第一问 n=0:10;f=[0.3,-0.2,0.4];g=[1,0,0];x=[1,2,3,4];figure h=impz(f,g,4);stem(h);
axis([0,6,-0.3,0.5]);title('用impz计算出的单位冲激响应的前5个值');
axis([0,10,0,2]);title('第一种方法,用filter,计算在传递函数作用下的x');figure y2=conv(h,x);stem(y2);axis([0,10,0,2]);title('第二种方法,用conv,计算h和x的卷积');
第五题第二问 n=0:10;f=[0.3,-0.2,0.4];g=[1,0.5,0];x=[1,2,3,4];figure h=impz(f,g,5);stem(h);
axis([0,6,-0.3,0.5]);title('用impz计算出的单位冲激响应的前5个值');figure
y1=filter(f,g,x);stem(y1);axis([0,10,0,2]);title('第一种方法,用filter,计算在传递函数作用下的x');figure y2=conv(h,x);stem(y2);axis([0,10,0,2]);title('第二种方法,用conv,计算h和x的卷积');