信号与系统课后matlab作业
- 格式:docx
- 大小:816.18 KB
- 文档页数:9
信号与系统课后matlab作业
This manuscript was revised on November 28, 2020 M2-1 (1) t=-2::4; T=2; xt=rectpuls(t-1,T); plot(t,xt) axis([-2,4,,]) 图象为: (2) t=sym('t'); y=Heaviside(t); ezplot(y,[-1,1]); grid on axis([-1 1 ]) 图象为: (3) A=10;a=-1;B=5;b=-2; t=0::10; xt=A*exp(a*t)-B*exp(b*t); plot(t,xt) 图象为: (4) t=sym('t'); y=t*Heaviside(t); ezplot(y,[-1,3]); grid on axis([-1 3 ]) 图象为: (5) A=2;w0=10*pi;phi=pi/6; t=0::; xt=abs(A*sin(w0*t+phi)); plot(t,xt) 图象为: (6) A=1;w0=1;B=1;w1=2*pi; t=0::20; xt=A*cos(w0*t)+B*sin(w1*t); plot(t,xt) 图象为: (7) A=4;a=;w0=2*pi; t=0::10; xt=A*exp(a*t).*cos(w0*t); plot(t,xt) 图象为: (8) w0=30; t=-15::15; xt=cos(w0*t).*sinc(t/pi); plot(t,xt) axis([-15,15,,]) 图象为: M2-3 (1)function yt=x2_3(t) yt=(t).*(t>=0&t<=2)+2*(t>=2&t<=3)-1*(t>=3&t<=5); (2) function yt=x2_3(t) yt=(t).*(t>=0&t<=2)+2*(t>=2&t<=3)-1*(t>=3&t<=5); t=0::6; subplot(3,1,1) plot(t,x2_3(t)) title('x(t)') axis([0,6,-2,3]) subplot(3,1,2) plot(t,x2_3*t)) title('x') axis([0,11,-2,3]) subplot(3,1,3) plot(t,x2_3*t)) title('x') axis([-6,5,-2,3]) 图像为: M2-9 (1) k=-4:7; xk=[-3,-2,3,1,-2,-3,-4,2,-1,4,1,-1]; stem(k,xk,'file') (2) k=-12:21; x=[-3,0,0,-2,0,0,3,0,0,1,0,0,-2,0,0,-3,0,0,-4,0,0,2,0,0,-1,0,0,4,0,0,1,0,0,-1]; subplot(2,1,1) stem(k,x,'file') title('3倍内插') t=-1:2; y=[-2,-2,2,1]; subplot(2,1,2) stem(t,y,'file') title('3倍抽取') axis([-3,4,-4,4]) (3) k=-4:7; x=[-3,-2,3,1,-2,-3,-4,2,-1,4,1,-1]; subplot(2,1,1) stem(k+2,x,'file') title('x[k+2]') subplot(2,1,2) stem(k-4,x,'file') title('x[k-4]') (4) k=-4:7; x=[-3,-2,3,1,-2,-3,-4,2,-1,4,1,-1]; stem(-fliplr(k),fliplr(x),'file') title('x[-k]') M3-1 (1) ts=0;te=5;dt=; sys=tf([2 1],[1 3 2]); t=ts:dt:te; x=exp(-3*t); y=lsim(sys,x,t); plot(t,y) xlabel('Time(sec)') ylabel('y(t)') (2) ts=0;te=5;dt=1; sys=tf([2 1],[1 3 2]); t=ts:dt:te; x=exp(-3*t); y=lsim(sys,x,t) y = 0
从(1)(2)对比我们当抽样间隔越小时数值精度越高。 M3-4 x=[,,,,,]; kx=-2:3; h=[,,,,]; kh=-1:3; y=conv(x,h); k=kx(1)+kh(1):kx(end)+kh(end); stem(k,y,'file'); M3-8 k=0:30; a=[1 ]; b=[ ]; h=impz(b,a,k); stem(k,h,'file') M4-1 (1)对于周期矩形信号的傅里叶级数cn =-1/2j*sin(n/2*pi)*sinc(n/2) n=-15:15; X=-j*1/2*sin(n/2*pi).*sinc(n/2); subplot(2,1,1); stem(n,abs(X),'file'); title('幅度谱') xlabel('nw'); subplot(2,1,2); stem(n,angle(X),'file'); title('相位谱')
(2)对于三角波信号的频谱是:Cn=-4n2π2+2nπsinnπ2+4n2π2cosnπ2 n=-15:15; X=sinc(n)*((sinc(n/2)).^2); subplot(2,1,1); stem(n,abs(X),'file'); title('幅度谱') xlabel('nw'); subplot(2,1,2); stem(n,angle(X),'file'); title('相位谱') M4-6(4) x=[1,2,3,0,0]; X=fft(x,5); subplot(2,1,1); m=0:4; stem(m,real(X),'file'); title('X[m]实部') subplot(2,1,2); stem(m,imag(X),'file'); title('X[m]虚部') M4-7(3) k=0:10; x=.^k; subplot(3,1,1); stem(k,x,'file') title('x[k]') X=fft(x,10); subplot(3,1,2); m=0:9; stem(m,real(X),'file'); title('X[m]实部') subplot(3,1,3); stem(m,imag(X),'file'); title('X[m]虚部') M5-2 t=0::; T=1; xt1=rectpuls,T); subplot(2,2,1) plot(t,xt1) title('x(t1)') axis([0,,0,2]) xt2=tripuls(t-1,2); subplot(2,2,2) plot(t,xt2) title('x(t2)') axis([0,,0,2]) xt=xt1+xt2.*cos(50*t); subplot(2,2,[3,4]) plot(t,xt) title('x(t)') figure; b=[10000]; a=[1,,,,10000]; w=linspace(0,2*pi,200); [H,w]=freqs(b,a,w); subplot(2,1,1) plot(w,abs(H)); title('幅度曲线') subplot(2,1,2) plot(w,angle(H)); title('相位曲线') figure; sys=tf([10000],[1 10000]); yt1=lsim(sys,xt,t); subplot(2,1,1); plot(t,yt1); title('y(t1)') yt2=lsim(sys,xt.*cos(50*t),t); subplot(2,1,2); plot(t,yt2); title('y(t2)') M6-1 (1) num=[]; den=[1 ]; [r,p,k]=residue(num,den) r = - + p = + - k =[] (2) num=[16 0 0]; den=[1 816 160000]; [r,p,k]=residue(num,den) r = - + + - p = + + k =[] (3) num=[1 0 0 0]; den=conv([1 5],[1 5 25]); [r,p,k]=residue(num,den) r = - + p = + - k =1 (4) num=[]; den=conv([1 ],[1 ]); [r,p,k]=residue(num,den) r = + - - + p = + - + - k =[] M6-2 sys=tf(b,a); x=1*(t>0)+0*(t<=0); y1=lsim(sys,x,t); plot(t,y1); title('零状态响应') figure;