中南民族大学信号与系统实验二 - 四 - 图文

更新时间:2024-05-02 17:40:01 阅读量: 综合文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

2.1

a=[1 2 2];b=[1 0];sys=tf(b,a); td=0.1;t=0:td:25;

f=1.*(t>=0);y=lsim(sys,f,t);

subplot(311);plot(t,y);xlabel('t(sec)');ylabel('y(t)');

h=impulse(sys,t);subplot(312);plot(t,h); xlabel('t(sec)');ylabel('h(t)');

g=step(sys,t);subplot(313);plot(t,g); xlabel('t(sec)');ylabel('g(t)'); 2.2

function[f,k]=dconv(f1,f2,k1,k2) f=conv(f1,f2);

k_start=k1(1)+k2(1);

k_end=length(f1)+length(f2)-2; k=k_start:(k_start+k_end); k1=-4:4; k2=-4:4;

f1=1.*(k1==-1)+2.*(k1==0)+1.*(k1==1); f2=1.*(k2>=-2)&(k2<3);

[f,k]=dconv(double(f1),double(f2),k1,k2); subplot(311);stem(k1,f1); subplot(312);stem(k2,f2); subplot(313);stem(k,f); 2.3

function[f,k]=cconv(f1,f2,k1,k2,td) f=td*conv(f1,f2); k_start=k1(1)+k2(1);

k_end=length(f1)+length(f2)-2; k=k_start:td:(k_start+k_end*td); td=0.01;k1=-4:td:4;k2=-4:td:4; f1=2.*(((k1+1)>=0)-((k1-1)>=0)); f2=((k2+2)>=0)-((k2-2)>=0);

[f,k]=cconv(double(f1),double(f2),k1,k2,td); subplot(311); plot(k1,f1); subplot(312);plot(k2,f2);

subplot(313);plot(k,f); 3.1

T=4;w=2*pi/T;

a0=quadl(@singrect,0,2)*2/T;

N=10;an=zeros(1,N);bn=zeros(1,N); for k=1:N

an(k)=quadl(@rectcos,0,2,[],[],k,w)*2/T;

bn(k)=quadl(@rectsin,0,2,[],[],k,w)*2/T; end;

n=1:1:N; figure(1);

subplot(1,2,1);plot(n,an,'-o');axis([0,10,-0.45,0.1]); grid on;

subplot(1,2,2);plot(n,bn,'-o');axis([0,10,-0.35,0.05]); grid on;

t=-6:0.01:6;

x=pulstran(t-0.5,-10:2:10,'tripuls',1,1); figure(2);subplot(6,2,1);plot(t,x); axis([-4,4,-1,2]);grid on;

subplot(6,2,2);plot(t,a0/2);grid on; wave=a0/2; for k=1:10

wave=wave+an(k)*cos(k)+bn(k)*sin(k*w*t);

subplot(6,2,k+2);plot(t,wave);grid on; end

function y=singrect(t); y=sawtooth(pi*t,1);

function y=rectcos(t,n,w);

y=sawtooth(pi*t,1).*cos(n*w*t); function y=rectsin(t,n,w);

y=sawtooth(pi*t,1).*sin(n*w*t); 3.2

R=0.005;t=-2:R:2; f=cos((pi/2)*t);

w1=40;N=1000;k=-N:N;w=k*w1/N; F=f*exp(-j*t'*w)*R; Fudu=real(F);

figure(1);

subplot(2,1,1);plot(t,f);

xlabel('t');ylabel('f(t)');grid on; subplot(2,1,2);plot(w,Fudu);

xlabel('w');ylabel('F(jw)');grid on; sf=cos((pi/2)*t*1/2);

w1=40;N=1000;k=-N:N;w=k*w1/N; SF=f*exp(-j*t'*w)*R; SFudu=real(SF); figure(2);

subplot(2,1,1);plot(t,sf);

xlabel('t');ylabel('sf(t)');grid on; subplot(2,1,2);plot(w,SFudu);

xlabel('w');ylabel('SF(jw)');grid on; mf=f.*cos(10*2*pi*t); figure(3);

subplot(3,1,1);plot(t,cos(10*pi*t)); ylabel('y(t)=cos(10*pi*t)');grid on; subplot(3,1,2);plot(t,mf);

ylabel('f1(t)=f(t)*cos(10*pi*t)');grid on;

MF=mf*exp(-j*t'*w)*R; MFudu=real(MF);

subplot(3,1,3);plot(w,MFudu);

xlabel('w');ylabel('MF(jw)');grid on; 3.3

R=0.005;t=-2:0.001:2; f=tripuls(t,2,0);

w1=40;N=1000;k=-N:N;w=k*w1/N; F=f*exp(-j*t'*w)*R; Fudu=real(F); figure(1);

subplot(2,1,1);plot(t,f);

xlabel('t');ylabel('f(t)');grid on; subplot(2,1,2);plot(w,Fudu);

xlabel('w');ylabel('F(jw)');grid on; mf=f.*cos(10*2*pi*t);figure(3);

subplot(3,1,1);plot(t,cos(10*2*pi*t)); ylabel('y(t)=cos(10*2*pi*t)');grid on; subplot(3,1,2);plot(t,mf);

ylabel('f1(t)=f(t)*cos(10*2*pi*t)');grid on;

MF=mf*exp(-j*t'*w)*R; MFudu=real(MF);

subplot(3,1,3);plot(w,MFudu);

xlabel('w');ylabel('MF(jw)');grid on; 3.4

b=[1 0];a=[1 3 2];w=linspace(0,5,200); H=freqs(b,a,w); figure(1);

subplot(2,1,1);plot(w,abs(H));

xlabel('\\omega');ylabel('|H(j\\omega)');

grid on;

subplot(2,1,2);plot(w,angle(H));

xlabel('\\omega');ylabel('\\phi');grid on; 1.5

k1=-1:4;k2=-5:1; f1=k1+1;f2=-k2+1;

[f1_new,f2_new,k]=duiqi(f1,k1,f2,k2); add_f=f1_new-f2_new; pro_f=f1_new.*f2_new;

subplot(221);stem(k1,f1);

axis([-1,4,0,6]);xlabel('k1');ylabel('f1=k1+1'); subplot(222);stem(k2,f2);

axis([-5,1,0,6]);xlabel('k2');ylabel('f2=-k2+1'); subplot(223);stem(k,add_f);

axis([-5,4,-6,6]);xlabel('k');ylabel('add_f'); subplot(224);stem(k,pro_f);

axis([-5,4,0,1]);xlabel('k');ylabe('pro_f'); 4.2

num=[1 0 -4];den=[1 2 -3 2 1]; zs=roots(num);ps=roots(den); figure(1);

plot(real(zs),imag(zs),'o',real(ps),imag(ps),'ks','markersize',12); axis([-2 2 -2 2]);grid on;

sys=tf(num,den);figure(2);pzmap(sys);axis([-2 2 -2 2]);

4.3

num=[1 4];den=[1 3 2];sys=tf(num,den); poles=roots(den);figure(1);pzmap(sys); t=0:0.02:10;h=impulse(num,den,t);

figure(2);plot(t,h);xlabel('t(s)');ylabel('h(s)');

[H,w]=freqs(num,den);

figure(3);plot(w,abs(H));

xlabel('\\omega(rad/s)');ylabel('|H(j\\omega))');

title('Magenitude Response');

4.1

num=[5];den=[1 1 44];[r,p,k]=residue(num,den); 结果:

r = -0.5000 - 0.2500i -0.5000 + 0.2500i 1.0000 + 0.0000i p =-0.0000 + 2.0000i -0.0000 - 2.0000i -1.0000 + 0.0000i k = [] 4.4

a)由图可知: H(s)=1/(s+2); num=[1];den=[1 2];

poles=roots(den) ;t=0:0.02:10; h=impulse(num,den,t); plot(t,h);

xlabel('t(s)');ylabel('h(t)');grid on; [H,w]=freqs(num,den);

figure(2);plot(w,abs(H));

xlabel('\\omega(rag/s)');ylabel('|H(j\\omega)|'); title('Magenitude Response');grid on; (b)由图可知:H(s)=1/((s+4j)(s-4j)); num=[1];den=conv([1 -4j],[1 4j]); poles=roots(den) t=0:0.02:10;

h=impulse(num,den,t); figure(1);plot(t,h);

xlabel('t(s)');ylabel('h(t)');grid on; [H,w]=freqs(num,den);

figure(2);plot(w,abs(H));

xlabel('\\omega(rag/s)');ylabel('|H(j\\omega)|');

title('Magenitude Response');grid on;

本文来源:https://www.bwwdw.com/article/yx1g.html

Top