您好,欢迎来到小侦探旅游网。
搜索
您的当前位置:首页MATLAB机考样题(带答案)

MATLAB机考样题(带答案)

来源:小侦探旅游网
MATLAB机考样题:

(1)Generate and plot sequence with20n20.

n = -20:20; n1=-20:20;

x1 = 2*cos(pi/8*n); x1=2*cos(pi/8*n1)

subplot(2,1,1) n2=n1-4;

stem(n,x1); x2=2*cos(pi/8*n2)

subplot(2,1,2) subplot(211)

stem(n+4,x1); plot(n1,x1);

subplot(212) plot(n2,x2)

?(2)Write a MATLAB program to compute and plot the impulse response of a causal finite-dimensional discrete-time system characterized by a difference equation of the following form:

x1[n]2cos(n) and x2[n]x1[n4],

8y[n]0.3y[n-1]0.5y[n-2]-0.72y[n-3]1.8x[n]0.34x[n-1]1.32x[n-2] 0.86x[n-3] N = input('input the points you want: '); N=input('请输入你要求的点数N='); num = [1.8 0.34 -1.32 -0.86]; num=[1.8 0.34 -1.32 -0.86]; den = [1 0.3 0.5 -0.72]; den=[1 0.3 0.5 -0.72]; [H,w] = freqz(num,den,N); %计算frequency response x=[1 zeros(1,N-1)]; subplot(2,1,1) y=filter(num,den,x) plot(w/pi,abs(H)); plot(0:N-1,y) title('magnitude response'); subplot(2,1,2) plot(w/pi,angle(H)); title('phase response');

(3)Write a MATLAB program to compute and display the poles and zeros, to compute and display the second-order factored form, and to generate the pole-zero plot of a z-transform that is a ratio of two polynomials in z-1. Using this program to analyze the following G(z):

H(z)8.16.93z23.82z10.5z11.52z10.18z20.1768z3

num=[8.1 6.93 -23.82 10.5]; den=[1 1.52 0.18 -0.1768]; sos=tf2sos(num,den) zplane(num,den)

123num = [8.1 6.93 -23.82 10.5]; den = [1 1.52 0.18 -0.1768]; [z,p,k] = tf2zp(num,den) zplane(z,p); [sos,G] = tf2sos(num,den) (4)Try to give a program to evaluate the following DTFT in the range 0 :

25ej9ej25ej33ej4G1(z)545ej2ej2ej3ej4

%由于用freqz计算频点至少是2个,所以至少输入两个频点 w1=input('请输入你要计算的频点w1='); w2=input('请输入你要计算的频点w2='); w=[w1 w2]; num=[2 5 9 5 3]; den=[5 45 2 1 1]; h=freqz(num,den,w)

points you want to N = input('input the subplot(2,2,3) compute: '); plot(w/pi,abs(h));grid num = [2 5 9 5 3]; title('Magnitude Spectrum') den = [5 45 2 1 1]; xlabel('\\omega/\\pi'); ylabel('Magnitude') [h,w] = freqz(num,den,N); subplot(2,2,4) subplot(2,2,1) plot(w/pi,angle(h));grid plot(w/pi,real(h));grid title('Phase Spectrum') title('Real part') xlabel('\\omega/\\pi'); ylabel('Phase, radians') xlabel('\\omega/\\pi'); ylabel('Amplitude') subplot(2,2,2) plot(w/pi,imag(h));grid title('Imaginary part') xlabel('\\omega/\\pi'); ylabel('Amplitude') (6)Write a MATLAB program to compute and plot the magnitude response of a causal LTI discrete-time system with a transfer function given by

0.15(1z2)H(z)10.5z10.7z2

num=0.15*[1 0 -1]; den=[1 -0.5 0.7];

[h,w]=freqz(num,den,512); plot(w/pi,abs(h))

(7)Consider the following FIR transfer function:

num = [0.15 0 -0.15]; den = [1 -0.5 0.7]; [h,w] = freqz(num,den); plot(w/pi,h) H(z)10.6z10.49z20.48z30.14z40.12z50.09z6

Using MATLAB to determine its zero locations and plot its magnitude and phase response.

h=[1 0.6 .49 -0.48 -0.14 -0.12 0.09]; figure(1) zplane(h,1);

[H,w]=freqz(h,1,512);

figure(2)

plot(w/pi,abs(H)) figure(3)

plot(w/pi,angle(H)) clear; num = [1 0.6 0.49 -0.48 -0.14 -0.12 0.09]; den = [1 0 0 0 0 0 0]; figure(1) [z,p,k] = tf2zp(num,den)%tf2zp(num,den)中num,den 的长度必须相等 zplane(num,den) [H,w] = freqz(num,den); figure(2) subplot(2,1,1) plot(w/pi,abs(H)); title('magnitude response'); subplot(2,1,2) plot(w/pi,angle(H)); title('phase response'); (8)Given a signal

x(t)4tcos0.1t, when using a sampling frequency

fT= 20KHz, plot the magnitude and phase spectrum of the sampled sequence(given

length-).

n = 0:63; fs=2e4;

n = n/(2*10^4); n=(0:63)/fs;

x = 4*n+cos(0.1*pi*n); x=4*n+cos(0.1*pi*n);

[H,w] = freqz(x,1); h=fft(x,512);

subplot(2,1,1) figure(1)

plot(w/pi,abs(H)); plot(0:2/511:2,abs(h))

title('magnitude spectrum'); figure(2)

subplot(2,1,2) plot(0:2/511:2,angle(h))

plot(w/pi,angle(H));

title('phase spectrum');

(9)design an IIR butterworth digital lowpass filter with the following specifications: sampling rate of 40kHz, passband edge frequency of 4kHz, stopband edge frequency of 8kHz, passband ripple of 0.5dB, and a minimum stopband attenuation of 40dB,plot frequency-magnitude and check if your design fits the specification.

fs=40; wp=4*2/fs; ws=8*2/fs; ap=0.5; as=40;

[n,wn]=buttord(wp,ws,ap,as);

Ft = 40000; [num,den]=butter(n,wn);

Fp = 4000; [h,w]=freqz(num,den,512);

Fs = 8000; figure(1)

deltap = 0.5; plot(w/pi,20*log10(abs(h)))

deltas = 40; axis([0 1 -50 0])

wp = 2*Fp/Ft; figure(2)

ws = 2*Fs/Ft; subplot(211)

[N,Wn] = buttord(wp,ws,deltap,deltas); plot(w/pi,20*log10(abs(h)))

[num,den] = butter(N,Wn); axis([0 wp -0.5 0]);

[H,w] = freqz(num,den); title('通带纹波')

plot(w/pi,20*log10(abs(H))); subplot(212)

title('gain response'); plot(w/pi,20*log10(abs(h))) axis([ws 1 -50 -30]) title('阻带纹波')

(10)Design a Hanning FIR lowpass filter meeting the following specifications: passband edge frequency=2kHz, stopband edge frequency=2.5kHz, passband ripple δp=0.005, stopband rippleδs=0.005, and sampling rate of 10kHz.Plot its gain and phase responses and check if it meets the specifications?

ft=10; fp=2; fs=2.5;

Wp=2/10*pi; Ws=2.5/10*pi; wp=2*pi*fp/ft;

dw=abs(Wp-Ws); ws=2*pi*fs/ft;

ds=0.005; ds=0.005;

ap=20*log10(1-ds) ap=20*log10(1-ds);

as=20*log10(ds) as=20*log10(ds)

M=3.11*pi/dw; wc=(wp+ws)/2;

N=ceil(2*M+1); dw=ws-wp;

Wc=(Wp+Ws)/(2*pi); M=ceil(3.11*pi/dw);

h=fir1(N,Wc,hann(N+1)); N=2*M;

[H,w]=freqz(h,1,512); b=fir1(N,wc/pi,hann(N+1));

subplot(2,1,1) [h,w]=freqz(b,1,512);

plot(w/pi,20*log10(abs(H))); figure(1)

title('gain response'); plot(w/pi,20*log10(abs(h)));

subplot(2,1,2) axis([0 1 -50 0])

plot(w/pi,angle(H)) title('magnitude response');

title('phase response'); figure(2)

plot(w/pi,unwrap(angle(h))); title('phase response');

figure(3) %局部放大,观察通带与阻带 subplot(211)

plot(w/pi,20*log10(abs(h))); axis([0 wp/pi ap 0])

title('通带纹波') subplot(212)

plot(w/pi,20*log10(abs(h))); axis([ws/pi 1 as 0]) title('阻带纹波')

%从图中可以看出,通带和阻带中纹波都不满足要求,所以不

满足指标

%as= -46.0206<43.9 所以不能用hanning窗设计 %应当用hamming或blackman窗设计

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- xiaozhentang.com 版权所有 湘ICP备2023022495号-4

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务