polyfit
Fit a polynomial to a set of paired data.
Syntax
p = polyfit(x,y,n)
[p,s,t] = polyfit(x,y,n)
Inputs
- x
- Values in first dimension of paired data.
- y
- Values in second dimension of paired data.
- n
- Order of the fit.
Outputs
- p
- The fitted polynomial coefficients, stored in descending order of powers.
- s
- A structure containing information about the fit. The following are supported.
- t
- A transform vector containing t(1)=mean(x) and t(2)=std(x). When t is present, x is shifted by t(1) and scaled by t(2) prior to the fit.
Example
Second order polyfit example.
p=polyfit([1,2,3,4],[4,8,18,32],2)
p = [Matrix] 1 x 3
2.50000 -3.10000 4.50000