POLYVAL Evaluate Polynomial Fit at Selected Points
Section: Optimization and Curve Fitting
polyvalroutine has the following syntax
y = polyval(p,x)
p is a vector of polynomial coefficients,
in decreasing degree (as generated by
polyfit, for example).
x is a matrix, the polynomial is evaluated in the matrix
sense (in which case
x must be square).
Function InternalsThe polynomial is evaluated using a recursion method. If the polynomial is
then the calculation is performed as
ExampleHere is a plot of
x^3generated using polyval
--> p = [1 0 0 0] p = 1 0 0 0 --> x = linspace(-1,1); --> y = polyval(p,x); --> plot(x,y,'r-')
Here is the resulting plot