% ***** MATLAB Code Starts Here %
%Z_TRANSFORM_03_MAT
%
fig_size = [232 84 774 624];
num = 20*conv([1 -.8],[1 -.7]);
% H(z) numeratorden = conv([1 -.5],conv([1 -.6],[1 .8]));
% H(z) denominator%
h = dimpulse(num,den);
% Impulse response using "dimpulse"n = [0:length(h)-1];
% discrete time vector%
[res,pol,fdth] = residue(num,[den 0]);
% PFE of H(z)/z%
h1 = res(1)*pol(1).^n + res(2)*pol(2).^n + res(3)*pol(3).^n;
h1(1) = h1(1)+res(4);
% Impulse response using "residue"%
figure(1),clf,stem(n,h1);grid,axis([0 25 -25 25]),
...xlabel(
'Discrete Time Samples'),ylabel('Amplitude'),...title(
'Impulse Response h(n)'),...set(gcf,
'Position',fig_size)%
% Magnitude and Phase of H(z) using "polyval" function
%
wt = [0:pi/20:pi];
% Angle vector (rad)z = exp(j*wt);
% Points on unit circle%
mag = abs(polyval(num,z)) ./ abs(polyval(den,z));
ph = unwrap(angle(polyval(num,z)) - angle(polyval(den,z)))*180/pi;
%
% Figures of magnitude and phase
%
figure(2),clf,plot(wt,20*log10(mag),wt,20*log10(mag),
'ko'),grid,...xlabel(
'Angle around unit circle (rad)'),...ylabel(
'Magnitude (db)'),title('Frequency Response Magnitude'),...set(gcf,
'Position',fig_size)%
figure(3),clf,plot(wt,ph,wt,ph,
'ko'),grid,...xlabel(
'Angle around unit circle (rad)'),...ylabel(
'Phase (deg)'),title('Frequency Response Phase'),...set(gcf,
'Position',fig_size)%
% % ***** MATLAB Code Stops Here
Click the
icon to return to the Dr. Beale's home page
Latest revision on 05/07/01 01:41 PM