Therefore, we can use the linear regression to find out a and b.
From matlab, I found some useful functions for linear regression:
1) Polynomial curve fitting :
p = polyfit(x,y,n)
p = polyfit(x,y,n) finds the coefficients of a polynomial p(x) of degree n that fits the data, p(x(i)) to y(i), in a least squares sense. The result p is a row vector of length n+1 containing the polynomial coefficients in descending powers
Source: http://www.mathworks.com/access/helpdesk/help/techdoc/ref/polyfit.html
y = polyval(p,x)
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.
Source: http://www.mathworks.com/access/helpdesk/help/techdoc/ref/polyval.html
没有评论:
发表评论