0
votes

I am trying to plot a zplot in Matlab that displays a unit circle, centered at 0 along with the poles and zeros of the plot. I am not allowed to use any other matlab function such as zplane or pzplot to do this. So far I am able to plot a unit circle just fine but I am having trouble getting my plot to display more of the axis without warping my circle. I also am having a heard time finding the poles and zeros of my function and also how to display the poles as little x's and the zeros as little o's on my plot. Any help would be greatly appreciated! My assignment looks like this and must correctly handle cases such as

zplot([0 1 1], [0 1]); zplot([0 1 1], [0 0 1]);

function zplot(b, a)

% ZPLOT Plot a zero-pole plot.

                                              -1 -nb
              B(z) b(1) + b(2)z + .... + b(nb+1)z

     H(z) = ---- = ---------------------------------

                                              -1 -na
              A(z) a(1) + a(2)z + .... + a(na+1)z

% zplot(b, a) plots the zeros and poles which determined by vectors b and a

% The plot includes the unit circle and axes for reference, plotted in black.

% Each zero is represented with a blue 'o' and each pole with a red 'x' on the 
%plot.

xmin;   
xmax;

ymin;   
ymax; 

% vector of angles at which points are drawn

angle = 0:2*pi/100:2*pi;            

% Unit radius

R = 1;               

% Coordinates of the circle

x = R*cos(angle);  
y = R*sin(angle);  

% Plot the circle

plot(x,y);                             
axis ([xmin, xmax, ymin, ymax]);

grid on;

end
2
Screenshots of the issue? A sample system or set of poles/zeros to test on?krisdestruction
It should be able to correctly handle things such as : zplot([0 1 1], [0 1]); zplot([0 1 1], [0 0 1]);KarmaPimp
Please update your question with the above. Please also post a screenshot visualizing the issue.krisdestruction
krisdestruction I am unable to post a screen shot of my plot because I don't have a high enough reputation. Sorry about that.KarmaPimp
Next time, just comment with a link or something and we can edit it for you. Check the solution below and accept it if it's correct.krisdestruction

2 Answers

1
votes

Given a transfer function G, you can use the pzplot() command and add a circle to it.

G = tf([1 4 1],[1 2 1]);

angle = [0:0.1:2*pi+0.1];
xp = cos(angle);
yp = sin(angle);

figure(1)
hold on
pzplot(G);
plot(xp,yp);
axis equal;

This should give you the pole-zero plot with x's for poles, o's for zeros, and the unit circle.

Here is the result.

enter image description here

1
votes

If you can't use pzplot() it is not hard. Here is a hint:

num = [1 4 1];%numerator coefficients of transfer function
den = [1 2 1];%denominator coefficients

z = roots(num)%zeros
p = roots(den)%poles

angle = 0:2*pi/100:2*pi;
xp = cos(angle);
yp = sin(angle);

figure(1)
scatter(z,zeros(length(z),1),'o');
hold on
scatter(p,zeros(length(p),1),'x');
plot(xp,yp);
axis equal

The output

enter image description here

Note that I haven't dealt with imaginary poles/zeros in this example. You'll need to calculate the proper x,y coordinates for a given imaginary pole or zero. (all the poles/zeros in this example are real, not imaginary)