MATLAB 机考样题:
(1)Generate and plot sequence
121[]2cos() [][4]8x n n and x n x n π
==-, with 20n 20-≤≤.
n1=-20:20;
x1=2*cos(pi/8*n1);
n2=n1-4;
x2=2*cos(pi/8*n2);
subplot(2,1,1);
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:
3]
-x[n 86.0 2]-1.32x[n 1]-0.34x[n x[n]8.13]-0.72y[n -2]-0.5y[n 1]-0.3y[n y[n]--+=++N=input('请输入你要求的点数N=');
num=[1.8 0.34 -1.32 -0.86];
den=[1 0.3 0.5 -0.72]; x=[1 zeros(1,N-1)];(单位冲击)
y=filter(num,den,x);
plot(0:N-1,y);
(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):
3213
211768.018.052.115.1082.2393.61.8)(-------+++-+=z z z z z z z H
num=[8.1 6.93 -23.82 10.5];
den=[1 1.52 0.18 -0.1768];
sos=tf2sos(num,den) %tf2sos 表示为1/z 的升幂
zplane(num,den)
(4)Try to give a program to evaluate the following DTFT in the range πω≤≤0 :
ωωωωω
ωωω4324321245535952)(j j j j j j j j e e e e e e e e z G --------++++++++=
%由于用freqz 计算频点至少是2个,所以至少输入两个频点