1、练习三实验三五1help windowWINDOW Window function gateway.WINDOW(WNAME,N) returns an N-point window of type specifiedby the function handle WNAME in a column vector. WNAME canbe any valid window function name, for example:bartlett - Bartlett window.barthannwin - Modified Bartlett-Hanning window. blackman -
2、Blackman window.blackmanharris - Minimum 4-term Blackman-Harris window.bohmanwin - Bohman window.chebwin - Chebyshev window.flattopwin - Flat Top window.gausswin - Gaussian window.hamming - Hamming window.hann - Hann window.kaiser - Kaiser window.nuttallwin - Nuttall defined minimum 4-term Blackman-
3、Harris window.parzenwin - Parzen (de la Valle-Poussin) window.rectwin - Rectangular window.tukeywin - Tukey window.triang - Triangular window.WINDOW(WNAME,N,OPT) designs the window with the optional input argumentspecified in OPT. To see what the optional input arguments are, see the helpfor the ind
4、ividual windows, for example, KAISER or CHEBWIN.WINDOW launches the Window Design w = window(blackmanharris,N);w1 = window(hamming,N);w2 = window(gausswin,N,2.5);plot(1:N,w,w1,w2); axis(1 N 0 1);legend(Blackman-Harris,Hamming,Gaussian);See also bartlett, barthannwin, blackman, blackmanharris, bohman
5、win, chebwin, gausswin, hamming, hann, kaiser, nuttallwin, parzenwin, rectwin, triang, tukeywin, wintool.Overloaded functions or methods (ones with the same name in other directories)help fdesign/window.mReference page in Help browserdoc window2.N = 128;w = window(rectwin,N);w1 = window(bartlett,N);
6、w2 = window(hamming,N);plot(1:N,w,w1,w2); axis(1 N 0 1);legend(矩形窗,Bartlett,Hamming);20 40 60 80 100 12000.10.20.30.40.50.60.70.80.91信 信 信BartlettHamming3.wvtool(w,w1,w2)20 40 60 80 100 12000.20.40.60.81SamplesAmplitudeTime domain0 0.2 0.4 0.6 0.8-120-100-80-60-40-200204060Normalized Frequency ( rad
7、/sample)Magnitude (dB)Frequency domain六ts=0.01;N=20;t=0:ts:(N-1)*ts;x=2*sin(4*pi*t)+5*cos(6*pi*t);g=fft(x,N);y=abs(g)/100;figure(1):plot(0:2*pi/N:2*pi*(N-1)/N,y);grid;0 1 2 3 4 5 600.050.10.150.20.250.30.350.40.45ts=0.01;N=30;t=0:ts:(N-1)*ts;x=2*sin(4*pi*t)+5*cos(6*pi*t);g=fft(x,N);y=abs(g)/100;figu
8、re(2):plot(0:2*pi/N:2*pi*(N-1)/N,y);grid;0 1 2 3 4 5 6 700.10.20.30.40.50.60.7ts=0.01;N=50;t=0:ts:(N-1)*ts;x=2*sin(4*pi*t)+5*cos(6*pi*t);g=fft(x,N);y=abs(g)/100;figure(3):plot(0:2*pi/N:2*pi*(N-1)/N,y);grid;0 1 2 3 4 5 6 700.10.20.30.40.50.60.70.80.91ts=0.01;N=100;t=0:ts:(N-1)*ts;x=2*sin(4*pi*t)+5*co
9、s(6*pi*t);g=fft(x,N);y=abs(g)/100;figure(4):plot(0:2*pi/N:2*pi*(N-1)/N,y);grid;0 1 2 3 4 5 6 700.511.522.5ts=0.01;N=150;t=0:ts:(N-1)*ts;x=2*sin(4*pi*t)+5*cos(6*pi*t);g=fft(x,N);y=abs(g)/100;figure(5):plot(0:2*pi/N:2*pi*(N-1)/N,y);grid;0 1 2 3 4 5 6 700.511.522.53实验八1%冲激响应 clear;b=1,3;a=1,3,2;sys=tf(
10、b,a);impulse(sys);结果:0 1 2 3 4 5 600.10.20.30.40.50.60.70.80.91信信信BartlettHmmingImpulse ResponseTime (sec)Amplitude%求零输入响应 A=1,3;0,-2;B=1;2;Q=ABQ =4-1 clearB=1,3;A=1,3,2;a,b,c,d=tf2ss(B,A)sys=ss(a,b,c,d);x0=4;-1;initial(sys,x0);grid;a =-3 -21 0b =10c =1 3d =00 1 2 3 4 5 600.20.40.60.811.21.4 Respons
11、e to Initial ConditionsTime (sec)Amplitude2.%冲激响应 clear;b=1,3;a=1,2,2;sys=tf(b,a);impulse(sys)0 1 2 3 4 5 6-0.200.20.40.60.811.2 Impulse ResponseTime (sec)Amplitude%求零输入响应 A=1,3;1,-2;B=1;2;Q=ABQ =1.6000-0.2000 clearB=1,3;A=1,2,2;a,b,c,d=tf2ss(B,A)sys=ss(a,b,c,d);x0=1.6;-0.2;initial(sys,x0);grid;a =-
12、2 -21 0b =10c =1 3d =00 1 2 3 4 5 6-0.200.20.40.60.811.21.41.6 Response to Initial ConditionsTime (sec)Amplitude3.%冲激响应 clear;b=1,3;a=1,2,1;sys=tf(b,a);impulse(sys)0 5 10 1500.20.40.60.811.21.4 Impulse ResponseTime (sec)Amplitude%求零输入响应 A=1,3;1,-1;B=1;2;Q=ABQ =1.7500-0.2500 clearB=1,3;A=1,2,1;a,b,c,
13、d=tf2ss(B,A)sys=ss(a,b,c,d);x0=1.75;-0.25;initial(sys,x0);grid;a =-2 -11 0b =10c =1 3d =00 5 10 1500.20.40.60.811.21.41.6 Response to Initial ConditionsTime (sec)Amplitude二 clear;b=1;a=1,1,1,0;sys=tf(b,a);subplot(2,1,1);impulse(sys);title(冲击响应);subplot(2,1,2);step(sys);title(阶跃响应 );t=0:0.01:20;e=sin
14、(t);r=lsim(sys,e,t);figure;subplot(2,1,1);plot(t,e);xlabel(Time);ylabel(A);title(激励信号);subplot(2,1,2);plot(t,r);xlabel(Time);ylabel(A);title(响应信号);0 2 4 6 8 10 12 14 16 18 2000.511.5 信信信信Time (sec)Amplitude0 2 4 6 8 10 12 14 16 18 2005101520 信信信信Time (sec)Amplitude0 2 4 6 8 10 12 14 16 18 20-1-0.500
15、.51TimeA信 信 信 信0 2 4 6 8 10 12 14 16 18 20-10123TimeA信 信 信 信三1. clear;b=1,3;a=1,3,2;t=0:0.08:8;e=exp(-3*t);sys=tf(b,a);lsim(sys,e,t);0 1 2 3 4 5 6 7 800.10.20.30.40.50.60.70.80.91 Linear Simulation ResultsTime (sec)Amplitude2. clear;b=1,3;a=1,2,2;t=0:0.08:8;sys=tf(b,a);step(sys)0 1 2 3 4 5 600.20.40
16、.60.811.21.41.6 Step ResponseTime (sec)Amplitude3 clear;b=1,3;a=1,2,1;t=0:0.08:8;e=exp(-2*t);sys=tf(b,a);lsim(sys,e,t);0 1 2 3 4 5 6 7 800.10.20.30.40.50.60.70.80.91 Linear Simulation ResultsTime (sec)AmplitudeDoc:1. clear;B=1;A=1,1,1;sys=tf(B,A,-1);n=0:200;e=5+cos(0.2*pi*n)+2*sin(0.7*pi*n);r=lsim(sys,e);stem(n,r); 0 20 40 60 80 100 120 140 160 180 200-30-20-1001020302. clear;B=1,1,1;A=1,-0.5,-0.5;sys=tf(B,A,-1);e=1,zeros(1,100);n=0:100;r=lsim(sys,e);stem(n,r); 0 10 20 30 40 50 60 70 80 90 10000.511.522.5