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(211)
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):
3
213
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)
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個,是以至少輸入兩個頻點
w1=input('請輸入你要計算的頻點w1=');
w2=input('請輸入你要計算的頻點w2=');
w=[w1 w2];