function x = plotpint (coef, x1, x2,numpoints)
%coef: polynom's coefficient array x1,x2 : intervals
%numpoints: the number of data points to be plotted
a=linspace(x1,x2,numpoints); % linspace of intervals and numpoints
b=polyval(coef,a); %values of given coef polynom for intervals
c=polyint(coef); % coef array of given coef's integral of polynom ( don't care here)
d=polyval(c,a); % values of c's polynom(integral of polynom) ( don't care here)
plot(a,b); % plotting polynom and integral of polynom
title('rer');
end我的plotpint函数在这里。例如,我想要p(x) = x^2-4,它的根是-2和+2,但是当我试图绘制这个多项式时,我的图显示根是0,如图所示。

我现在该怎么做?我哪里错了?如何解决这个问题?
发布于 2014-04-17 04:19:03
没有问题,您已经正确地绘制了y = x*x + 0*x + 4 (根据您的coef值)。
我确实注意到,在这种缩放级别下,很难区分.0004 * 10^4和.0000 * 10^4。使用range -5:5而不是-150:150,您可能会更容易看到发生了什么。
FWIW,当在MATLAB中解释任何图形时,首先查看轴比例。

https://stackoverflow.com/questions/23118801
复制相似问题