Z-plane and its responses using Matlab December 14, 2008

Posted by haryoktav in Taipei.

If you want to plot z-plane in Matlab, just use zplane command. This example is taken from example 5.10 from textbook “Discrete-time Signal Processing 2nd Ed, Oppenheim” ```z = [-1  exp(1.0376j) exp(-1.0376j)]';                        % zeros
p = [0.683 0.892*exp(0.6257j) 0.892*exp(-0.6257j)]';    % poles
k = 0.05634;                                                        % gain
zplane(z,p);        % plot z-plane
title('Z-plane');
grid

```

And now, this is how to plot magnitude respons, phase response and group delay.

```% -----------------------------------------------
% Frequency response
% -----------------------------------------------
[b a] = zp2tf(z,p,k);			% Zero-pole to transfer function conversion
[h, w] = freqz(b,a,N);			% Digital filter frequency response

figure(1);subplot(131);plot(w/pi,abs(h));		% plot magnitude
title('Magnitude response');
grid
xlabel('Normalized freq. (Nyquist freq. = 1)')
ylabel('response magnitude');

figure(1);subplot(132);plot(w/pi,angle(h));	% plot angle
title('Phase response');
grid
xlabel('Normalized freq.(Nyquist freq. = 1)')

% -----------------------------------------------
% Group delay
% -----------------------------------------------
[gd, w] = grpdelay(b,a);		%Group delay of a digital filter

figure(1);subplot(133);plot(w/pi,gd);	% plot group delay
title('Group delay');
grid
xlabel('Normalized freq. (Nyquist freq. = 1)')
ylabel('delay (in samples)');

``` That figure is plotted from 0 to pi. I dunno how to plot from -pi to pi, or from 0 to 2pi. Overall, that was a nice figure, isn’t it? 1. maciek - December 5, 2012 haryoktav - December 6, 2012 2. santosh - January 11, 2013