Clear Filters
Clear Filters

How to make the zplane function to plot on a existing axes?

10 views (last 30 days)
The zplane function always create a new plot. HOW to let it on a exisiting axes? Or any workaround?

Accepted Answer

Paul
Paul on 13 Feb 2022
Edited: Paul on 13 Feb 2022
You can specify an existing axis via a third argument. I didn't see this on the doc page, but it does show up in the help,
help zplane
ZPLANE Z-plane zero-pole plot. ZPLANE(Z,P) plots the zeros Z and poles P (in column vectors) with the unit circle for reference. Each zero is represented with a 'o' and each pole with a 'x' on the plot. Multiple zeros and poles are indicated by the multiplicity number shown to the upper right of the zero or pole. ZPLANE(Z,P) where Z and/or P is a matrix, plots the zeros or poles in different columns using the colors specified by the axes ColorOrder property. ZPLANE(B,A) where B and A are row vectors containing transfer function polynomial coefficients plots the poles and zeros of B(z)/A(z). Note that if B and A are both scalars they will be interpreted as Z and P. [HZ,HP,Hl] = ZPLANE(Z,P) returns vectors of handles to the lines and text objects generated. HZ is a vector of handles to the zeros lines, HP is a vector of handles to the poles lines, and Hl is a vector of handles to the axes / unit circle line and to text objects which are present when there are multiple zeros or poles. In case there are no zeros or no poles, HZ or HP is set to the empty matrix []. ZPLANE(Z,P,AX) puts the plot into the axes specified by the handle AX. [HZ,HP,Hl] = ZPLANE(D) plots the poles and zeros of digital filter D. You design a digital filter, D, by calling the designfilt function. % Example 1: % Design a lowpass FIR filter with normalized cut-off frequency at % 0.3 and show its zero-pole plot. b=fircls1(54,0.3,0.02,0.008); zplane(b) % zero-pole plot for filter % Example 2: % Design a 5th order lowpass elliptic IIR filter and show its % zero-pole plot. [b,a] = ellip(5,0.5,20,0.4); zplane(b,a) % zero-pole plot for filter % Example 3: % Design a lowpass Butterworth IIR filter and show its Zero-Pole % plot. [z,p] = butter(4,0.15); zplane(z,p) % zero-pole plot for filter % Example 4: % Use the designfilt function to design a highpass IIR digital filter % with order 8, passband frequency of 75 KHz, and a passband ripple % of 0.2 dB. Sample rate is 200 KHz. Visualize the zero-pole plot. D = designfilt('highpassiir', 'FilterOrder', 8, ... 'PassbandFrequency', 75e3, 'PassbandRipple', 0.2,... 'SampleRate', 200e3); zplane(D) See also FREQZ, GRPDELAY, IMPZ, FVTOOL. Documentation for zplane doc zplane
The following code works fine on my local installation. It results in a figure with three lines and the zplane pole/zero plot..Don't know why it's not working here?
figure;
rng(101);
plot(rand(3));
hax = gca;
zplane([1 2 3],[3 2 1],hax)
Here is the figure I get on my machine:
  2 Comments
Paul
Paul on 14 Feb 2022
There should be link or something similar at the bottom of the doc page that allows you to provide feedback on a doc page if you wish.

Sign in to comment.

More Answers (1)

Voss
Voss on 13 Feb 2022
Edited: Voss on 13 Feb 2022
I don't think you can do that with zplane(), but you can, in your own axes, fairly easily reproduce the lines that zplane() creates:
% First a zplane plot for reference:
[b,a] = ellip(4,3,30,200/500);
zplane(b,a);
% Now a new figure and axes with some stuff in it:
figure();
plot(linspace(-1,1,10),linspace(-1,1,10),'rs','LineWidth',2);
hold on
% Now, plotting what zplane(b,a) would plot:
axis equal
z = roots(b);
p = roots(a);
t = linspace(0,2*pi,1000);
blue = [0 0.447 0.741];
xl = get(gca(),'XLim');
yl = get(gca(),'YLim');
line(xl,[0 0],'Color',blue,'LineStyle',':','LineWidth',0.5);
line([0 0],yl,'Color',blue,'LineStyle',':','LineWidth',0.5);
line(cos(t),sin(t),'Color',blue,'LineStyle',':','LineWidth',0.5);
line(real(z),imag(z),'Color',blue,'LineStyle','none','Marker','o','MarkerSize',7);
line(real(p),imag(p),'Color',blue,'LineStyle','none','Marker','x','MarkerSize',8);
xlabel('Real Part');
ylabel('Imaginary Part');

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!