Note: This page has been translated by MathWorks. Please click here

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Polynomial evaluation

`y = polyval(p,x)`

[y,delta] = polyval(p,x,S)

y = polyval(p,x,[],mu)

[y,delta]
= polyval(p,x,S,mu)

`y = polyval(p,x)`

returns
the value of a polynomial of degree `n`

evaluated
at `x`

. The input argument `p`

is
a vector of length `n+1`

whose elements are the coefficients
in descending powers of the polynomial to be evaluated.

*y* = *p*_{1}*x ^{n}* +

`x`

can be a matrix or a vector. In either
case, `polyval`

evaluates `p`

at
each element of `x`

.

`[y,delta] = polyval(p,x,S)`

uses
the optional output structure `S`

generated by `polyfit`

to
generate error estimates `delta`

. `delta`

is
an estimate of the standard deviation of the error in predicting
a future observation at `x`

by `p(x)`

.
If the coefficients in `p`

are least squares estimates
computed by `polyfit`

, and the errors in the data
input to `polyfit`

are independent, normal, and have
constant variance, then `y`

±`delta`

contains
at least 50% of the predictions of future observations at `x`

.

`y = polyval(p,x,[],mu)`

or ```
[y,delta]
= polyval(p,x,S,mu)
```

use $$\widehat{x}=(x-{\mu}_{1})/{\mu}_{2}$$ in
place of `x`

. In this equation, $${\mu}_{1}=\text{mean}(x)$$ and $${\mu}_{2}=\text{std}(x)$$. The centering and scaling parameters `mu`

= [*μ*_{1},*μ*_{2}]
are optional output computed by `polyfit`

.

The polynomial $$p(x)=3{x}^{2}+2x+1$$ is evaluated at *x* =
5, 7, and 9 with

p = [3 2 1]; polyval(p,[5 7 9])

which results in

ans = 86 162 262

For another example, see `polyfit`

.

The `polyvalm(p,x)`

function, with `x`

a
matrix, evaluates the polynomial in a matrix sense. See `polyvalm`

for
more information.

Was this topic helpful?