2015-04-23 47 views
0

我想绘制一个zplot,在Matlab中显示一个单位圆,以0为中心以及绘图的极点和零点。我不允许使用任何其他matlab函数,例如zplane或pzplot来执行此操作。到目前为止,我可以绘制一个单位圆,但我无法让我的绘图显示更多的坐标轴而不会扭曲我的圆。我也有一段时间了解我的功能的极点和零点,以及如何在我的情节中显示极小的x和零的极点。任何帮助将不胜感激!我的任务看起来像这样,并且必须正确处理诸如使用Matlab绘制zplot

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 
+1

问题的屏幕截图?一个样本系统或一组要测试的极点/零点? – krisdestruction

+0

它应该能够正确处理诸如:zplot([0 1 1],[0 1]); zplot([0 1 1],[0 0 1]); – KarmaPimp

+0

请用上面的方法更新你的问题。请同时发布可视化问题的截图。 – krisdestruction

回答

1

如果您不能使用pzplot()也不是很难。这里是一个暗示:

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 

输出

enter image description here

请注意,我没有处理在本例中虚构的极点/零点。您需要计算给定虚极或零点的正确x,y坐标。 (在这个例子中所有的极点/零点都是真实的,而不是虚构的)

+0

非常感谢!我想我可以从这里找出其余的东西!你真棒负鼠:D – KarmaPimp

1

给定一个传递函数G,可以使用pzplot()命令并为其添加一个圆。

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; 

这应该给你极点 - 零点图,其中x为极点,o为零点和单位圆。

这是结果。

enter image description here

+0

为你加了图像。看起来正确+1 – krisdestruction

+0

角度对我不起作用,我必须使用角度= 0:2 * pi/100:2 * pi;因为它在我的Matlab版本上绘制了圆,但两个版本看起来完全一样。 – KarmaPimp

+0

非常感谢您的帮助!但我不想使用任何预先存在的matlab函数,例如zplane的pzplot。还有什么建议? – KarmaPimp