MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   八度/ Matlab:如何绘制多项式的根 (https://www.labfans.com/bbs/showthread.php?t=23203)

poster 2019-12-10 20:30

八度/ Matlab:如何绘制多项式的根
 
我试图绘制多项式的根,但我无法理解。

首先,我创建我的多项式

p5 = [1 0 0 0 0 -1] %x^5 - 1 r5 = roots(p5) stem (p5) 我正在使用stem功能,但我想删除词干,只获得围绕根的圆。

这有可能吗,干正确的命令吗?

提前致谢,

PS:这不是家庭作业,但是非常紧密,如果需要,可以标记它。



[B]回答:[/B]

如果您想使用x轴上的实部和y轴上的虚部进行绘制的复杂根,则可以使用[URL="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/plot.html"]PLOT[/URL]函数:

plot(r5,'o'); 如果要将函数[I]和[/I]根一起绘制,则必须忽略复杂的根(如yuk在下面的评论中所述):

p5 = [1 0 0 0 0 -1]; r5 = roots(p5); realRoots = r5(isreal(r5)); %# Gets just the real roots x = -2:0.01:2; %# x values for the plot plot(x,polyval(p5,x)); %# Evaluate the polynomial and plot it hold on; %# Add to the existing plot plot(realRoots,zeros(size(realRoots)),'o'); %# Plot circles for the roots

[url=https://stackoverflow.com/questions/2441218]更多&回答...[/url]


所有时间均为北京时间。现在的时间是 04:54

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.