Version:

Last Modified: March 15, 2017

Computes a polynomial of a specified degree that fits the input data using the least-squares method.

[p, s] = polyfit(x, y, n)

[p, s, mu] = polyfit(x, y, n)

X-coordinates of the data you want to fit. x is a vector.

Y-coordinates of the data you want to fit. y is a vector of the same length as x.

Degree of the polynomial you want to fit against x and y. n must be less than the length of x. n is a positive integer.

Coefficients in descending order of the polynomial fit. p is a vector.

Cholesky factor of the Vandermonde matrix. s is a structure with the following fields.

Name | Description |
---|---|

R | Cholesky factor of the Vandermonde matrix. |

df | Degree of freedom. |

normr | Norm of the residue. |

Mean and standard deviation of x. MathScript uses these values to normalize x to improve the fit. mu is a vector. The first element of mu is the mean, and the second element of mu is the standard deviation.

[P, S] = polyfit(1:10, rand(1, 10), 5)

[P, S, MU] = polyfit(1:10, [3, 3, 3, 4, 5, 6, 10, 12, 14, 15], 5)

**Where This Node Can Run: **

Desktop OS: Windows

FPGA: This product does not support FPGA devices