信号与系统matlab作业.docx
《信号与系统matlab作业.docx》由会员分享,可在线阅读,更多相关《信号与系统matlab作业.docx(32页珍藏版)》请在冰豆网上搜索。
信号与系统matlab作业
《信号与系统》matlab作业
M2-1
(1)t=0:
0.001:
4
f=rectpuls(t-1,2)
plot(t,f)
xlabel('t');ylabel('f(t)');
axis([0,4,0,2])
(2)t=-2:
0.02:
6;
x=(t>=0);
plot(t,x);
axis([-1302]);
(3)t=-2:
0.02:
6;
x=10*exp(-1*t)-5*exp(-2*t);
plot(t,x);
xlabel('t');ylabel('x');
(4)t=-2:
0.02:
6
x=(t>=0);
y=t.*x;
plot(t,y);
(5)t=-0.1*pi:
0.001:
0.1*pi;
x=2*abs(sin(10*pi*t+pi/3));
xlabel('t');ylabel('x(t)');
plot(t,x);
axis([-0.1*pi,0.1*pi,0,2])
(6)t=-2:
0.002:
2;
x=cos(t)+sin(2*pi*t);
xlabel('t');ylabel('x');
plot(t,x);
(7)t=-20:
0.02:
20;
x=4*exp(-0.5*t).*cos(2*pi*t);
xlabel('t');ylabel('x');
plot(t,x);
(8)t=-2:
0.02:
2;
x=sinc(t).*cos(30*t);
xlabel('t');ylabel('x');
plot(t,x);
M2-3
(1)functionyt=x2_3(t)
yt=t.*(t>0&t<=2)+2*(t>2&t<=3)-1*(t>3&t<=5)
(2)t=-20:
0.001:
20
subplot(3,1,1)
plot(t,x2_3(t))
title('x(t)')
axis([-12,12,-2,4])
subplot(3,1,2)
plot(t,x2_1(0.5*t))
title('x(0.5t)')
axis([-12,12,-2,4])
subplot(3,1,3)
plot(t,x2_1(2-0.5*t))
title('x(2-0.5t)')
axis([-12,12,-2,4])
M2-9
(1)k=-4:
7;
x=[-3-231-2-3-42-141-1];
stem(k,x)
(2)
插值:
k=-12:
21;
x=[-3,-2,3,1,-2,-3,-4,2,-1,4,1,-1];
N=length(x);
y=zeros(1,3*N-2);
y(1:
3:
end)=x;
stem(k,y)
抽值:
x=[0,0,-3,-2,3,1,-2,-3,-4,2,-1,4,1,-1];
y=x(1:
3:
end);
k=-1:
3;
stem(k-1,y)
(3)
k=-4:
7;
m=k-2;
xm=[-3,-2,3,1,-2,-3,-4,2,-1,4,1,-1];
n=k+4;
xn=[-3,-2,3,1,-2,-3,-4,2,-1,4,1,-1];
subplot(2,1,1)
stem(m,xm)
axis([-3,6,-5,5])
title('x[k+2]')
subplot(2,1,2)
stem(n,xn)
title('x[k+4]')
axis([-2,12,-5,5])
(4)
k=-7:
4;
x=[-3,-2,3,1,-2,-3,-4,2,-1,4,1,-1];
y=fliplr(x);
stem(k,y)
M3-1
(1)t=0:
0.01:
10
sys=tf([2,1],[1,3,2])
x=exp(-3*t).*(t>=0)
y=lsim(sys,x,t)
plot(t,y)
(2)
M3-4
k=-2:
3
x=[0.850.530.210.670.840.12]
m=-1:
3
h=[0.680.370.830.520.71]
y=conv(x,h)
N=length(y)
stem(0:
N-1,y)
M3-8
k=0:
30
a=[10.7-0.45-0.6]
b=[0.8-0.440.360.02]
impz(b,a,k)
stem(k,h)
M4-1
(1)
N=20;
n1=-N:
-1;
c1=1/2.*sinc(n1/2).*exp(-j*n1*pi*1/2);
c0=(1/2.*sinc(0/2)).*exp(-1*j*0*pi*1/2)-1/2;
n2=1:
N;
c2=1/2.*sinc(n2/2).*exp(-1*j*n2.*pi*1/2);
cn=[c1c0c2];
n=-N:
N;
subplot(2,1,1);
stem(n,abs(cn));ylabel('Cn的幅度');
subplot(2,1,2);
stem(n,angle(cn));
ylabel('Cn的相位');xlabel('\omega/\omega0');
(2)N=8;
n1=-N:
-1;
c1=-2*j*sin(n1*pi/2)/pi^2./n1.^2.*exp(-j*n1*1/2);
c0=-2*j*sin(0*pi/2)/pi^2./0.^2.*exp(-j*0*1/2)+2*pi;
n2=1:
N;
c2=-2*j*sin(n2*pi/2)/pi^2./n2.^2.*exp(-j*n2*1/2);
cn=[c1c0c2];
n=-N:
N;
subplot(2,1,1);
stem(n,abs(cn));ylabel('Cn的幅度');
subplot(2,1,2);
stem(n,angle(cn));
ylabel('Cn的相位');xlabel('\omega/\omega0');
M4-6
(4)k=0:
5
x=[1,2,3,0,0]
X=fft(x)
m=0:
4
subplot(2,1,1)
stem(m,real(X))
title('X[m]的实部')
xlabel('m')
subplot(2,1,2)
stem(m,imag(X))
title('X[m]的虚部')
xlabel('m')
subplot(2,1,2)
M4-7
(3)k=0:
10
a=0.5
xk=a.^k
X=fft(xk)
m=0:
10
stem(m,real(X))
title('X[m]的实部')
xlabel('m')
figure
stem(m,imag(X))
title(‘X[m]的虚部’)
xlabel('m')
xr=ifft(X)
figure
stem(m,real(xr))
xlabel('k')
title('重建的x[k]')
M5-2
(1)t=0:
0.05:
2.5
x1t=1.*(t>=0&t<=1)
subplot(3,1,1)
plot(t,x1t)
xlabel('t')
ylabel('x1t')
axis([0,2.5,-2,2])
x2t=t.*(t>=0&t<=1)+(2-t).*(t>1&t<=2)
subplot(3,1,2)
plot(t,x2t)
xlabel('t')
ylabel('x2t')
x3t=x1t+x2t.*cos(50*t)
subplot(3,1,3)
plot(t,x3t)
xlabel('t')
ylabel('x3t')
(2)w=linspace(0,2*pi,200)
b=[10000]
a=[1,26.131,341.42,2613.1,10000]
H=freqs(b,a,w)
subplot(2,1,1)
plot(w,abs(H))
xlabel('\omega')
ylabel('abs(H(j\omega))')
subplot(2,1,2)
plot(w,angle(H))
xlabel('\omega')
ylabel('\phi(H(j\omega))')
(3)t=0:
0.05:
2.5
x1t=1.*(t>=0&t<=1)
x2t=t.*(t>=0&t<=1)+(2-t).*(t>1&t<=2)
xt=x1t+x2t.*cos(50*t)
H=tf([10000],[1,26.131,341.42,2613.1,10000])
yt=lsim(H,x3t,t)
subplot(2,1,1)
plot(yt,t)
xlabel('t')
ylabel('y1(t)')
x4t=x3t.*cos(50*t)
y2t=lsim(H,x4t,t)
subplot(2,1,2)
plot(y2t,t)
xlabel('t')
ylabel('y2(t)')
M6-1
(1)num=[41.6667]
den=[1,3.7444,25.7604,41.6667]
[r,p,k]=residue(num,den)
[angle,mag]=cart2pol(real(r),imag(r))
运行结果:
r=
-0.9361-0.1895i
-0.9361+0.1895i
1.8722
p=
-0.9361+4.6237i
-0.9361-4.6237i
-1.8722
k=
[]
angle=
-2.9418
2.9418
0
mag=
0.9551
0.9551
1.8722
由此可得:
X(s)=
+
-1
(2)
num=[16,0,0]
den=[1,5.6569,816,2262.7,160000]
[r,p,k]=residue(num,den)
[angle,mag]=cart2pol(real(r),imag(r))
运行结果:
r=
0.0992-1.5147i
0.0992+1.5147i
-0.0992+1.3137i
-0.0992-1.3137i
p=
-1.5145+21.4145i
-1.5145-21.4145i
-1.3140+18.5860i
-1.3140-18.5860i
k=
[]
angle=
-1.5054
1.5054
1.6462
-1.6462
mag=
1.5180
1.5180
1.3175
1.3175
(3)
num=[1,0,0,0]
den=conv([1,5],[1,5,25])
[r,p,k]=residue(num,den)
[angle,mag]=cart2pol(real(r),imag(r))
运行结果:
r=
-2.5000-1.4434i
-2.5000+1.4434i
-5.0000
p=
-2.5000+4.3301i
-2.5000-4.3301i
-5.0000
k=
1
angle=
-2.6180
2.6180
3.1416
mag=
2.8868
2.8868
5.0000
(4)
num=[833.3025]
den=conv([1,4.1123,28.867],[1,9.9279,28.867])
[r,p,k]=residue(num,den)
[angle,mag]=cart2pol(real(r),imag(r))
运行结果:
r=
2.4819-5.9928i
2.4819+5.9928i
-2.4819+1.0281i
-2.4819-1.0281i
p=
-4.9640+2.0558i
-4.9640-2.0558i
-2.0562+4.9638i
-2.0562-4.9638i
k=
[]
angle=
-1.1782
1.1782
2.7489
-2.7489
mag=
6.4864
6.4864
2.6864
2.6864
M6-2
t=0:
0.001:
10
sys=tf([2,1],[1,4,3])
x=1.*(t>=0)
yzs=lsim(sys,x,t)
subplot(2,1,1)
plot(t,yzs)
xlabel('t')
ylabel('yzs(t)')
eq='D2y+4*Dy+3*y=0';
cond='y(0)=1,Dy(0)=2';
yzi=simplify(dsolve(eq,cond))
t=0:
0.001:
10
sys=tf([2,1],[1,4,3])
x=1.*(t>=0)
yzs=lsim(sys,x,t)
subplot(2,1,1)
plot(t,yzs)
xlabel('t')
ylabel('yzs(t)')
yzi=5/2.*exp(-t)-3/2.*exp(-3*t)
subplot(2,1,2)
plot(t,yzi)
xlabel('t')
ylabel('yzi(t)')
M6-5
num=[1,2]
den=[1,2,2,1]
sys=tf(num,den)
subplot(4,1,1)
pzmap(sys)
t=0:
0.02:
10
w=0:
0.02:
5
h=impulse(num,den,t)
subplot(4,1,2)
plot(t,h)
xlabel('t')
ylabel('h(t)')
y=step(num,den,t)
subplot(4,1,3)
plot(t,y)
xlabel('t')
ylabel('阶跃响应')
H=freqs(num,den,w)
subplot(4,1,4)
plot(w,abs(H))
xlabel('\omega')
ylabel('幅度响应')
M7-1
(1)
num=[2,16,44,56,32]
den=[3,3,-15,18,-12]
[r,p,k]=residuez(num,den)
运行结果:
r=
-0.0177
9.4914
-3.0702+2.3398i
-3.0702-2.3398i
p=
-3.2361
1.2361
0.5000+0.8660i
0.5000-0.8660i
k=
-2.6667
X[k]=-2.6667+
+
+
+
(2)
num=[4,-8.68,-17.98,26.74,-8.04]
den=[1,-2,10,6,65]
[r,p,k]=residuez(num,den)
运行结果:
r=
1.0971+1.3572i
1.0971-1.3572i
0.9648-1.2511i
0.9648+1.2511i
p=
2.0000+3.0000i
2.0000-3.0000i
-1.0000+2.0000i
-1.0000-2.0000i
k=
-0.1237
X[k]=-0.1237+
+
+
+
M7-2
num=[12-3-1.5]
den=[2-41.5]
k=0:
10
k1=length(k)
y01=[13]
x01=[00]
x1=zeros(1,k1)
z1=filtic(num,den,y01,x01)
yi=filter(num,den,x1,z1)
subplot(3,1,1)
stem(k,yi)
title('零输入响应')
y02=[00]
x02=[00]
x2=0.5.^k
z2=filtic(num,den,y02,x02)
yz=filter(num,den,x2,z2)
subplot(3,1,2)
stem(k,yz)
title('零状态响应')
y03=[13]
x03=[00]
x3=0.5.^k
z3=filtic(num,den,y03,x03)
y=filter(num,den,x1,z3)
subplot(3,1,3)
stem(k,y)
title('全响应')
M7-3
(1)
num=[2,16,44,56,32]
den=[3,3,-15,18,-12]
[z,p,k]=tf2zp(num,den)
zplane(num,den)
系统不稳定
(2)
num=[4,-8.68,-17.98,26.74,-8.04]
den=[1,-2,10,6,65]
[z,p,k]=tf2zp(num,den)
zplane(num,den)
系统不稳定