Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
|
![]() |
#1 |
高级会员
注册日期: 2019-11-21
帖子: 3,006
声望力: 66 ![]() |
![]()
我试图绘制多项式的根,但我无法理解。
首先,我创建我的多项式 p5 = [1 0 0 0 0 -1] %x^5 - 1 r5 = roots(p5) stem (p5) 我正在使用stem功能,但我想删除词干,只获得围绕根的圆。 这有可能吗,干正确的命令吗? 提前致谢, PS:这不是家庭作业,但是非常紧密,如果需要,可以标记它。 回答: 如果您想使用x轴上的实部和y轴上的虚部进行绘制的复杂根,则可以使用PLOT函数: plot(r5,'o'); 如果要将函数和根一起绘制,则必须忽略复杂的根(如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 更多&回答... |
![]() |
![]() |