| Statistics Toolbox | ![]() |
Syntax
Description
Y = polyval(p,X)
returns the predicted value of a polynomial given its coefficients, p, at the values in X.
[Y,DELTA] = polyval(p,X,S)
uses the optional output S generated by polyfit to generate error estimates, Y ± DELTA. If the errors in the data input to polyfit are independent normal with constant variance, Y ± DELTA contains at least 50% of the predictions.
If p is a vector whose elements are the coefficients of a polynomial in descending powers, then polyval(p,X) is the value of the polynomial evaluated at X. If X is a matrix or vector, the polynomial is evaluated at each of the elements.
The polyval function is part of the standard MATLAB language.
Examples
Simulate the function y = x, adding normal random errors with a standard deviation of 0.1. Then use polyfit to estimate the polynomial coefficients. Note that predicted Y values are within DELTA of the integer X in every case.
[p,S] = polyfit(1:10,(1:10) + normrnd(0,0.1,1,10),1); X = magic(3); [Y,D] = polyval(p,X,S) Y = 8.0696 1.0486 6.0636 3.0546 5.0606 7.0666 4.0576 9.0726 2.0516 D = 0.0889 0.0951 0.0861 0.0889 0.0861 0.0870 0.0870 0.0916 0.0916
See Also
polyfit, polytool, polyconf
| polytool | prctile | ![]() |