作业帮 > 英语 > 作业

matlab 作拟合的直线

来源:学生作业帮 编辑:拍题作业网作业帮 分类:英语作业 时间:2024/04/29 12:07:10
matlab 作拟合的直线
例如x,y如下
x=[12.10 11.96 11.80 11.65 11.50];
y=[23.00 34.00 45.00 56.00 67.00];
并求直线的斜率
能不能说得再清楚些
help polyfit
POLYFIT Fit polynomial to data.
POLYFIT(X,Y,N) finds the coefficients of a polynomial P(X) of
degree N that fits the data,P(X(I))~=Y(I),in a least-squares sense.
[P,S] = POLYFIT(X,Y,N) returns the polynomial coefficients P and a
structure S for use with POLYVAL to obtain error estimates on
predictions.If the errors in the data,Y,are independent normal
with constant variance,POLYVAL will produce error bounds which
contain at least 50% of the predictions.
The structure S contains the Cholesky factor of the Vandermonde
matrix (R),the degrees of freedom (df),and the norm of the
residuals (normr) as fields.
[P,S,MU] = POLYFIT(X,Y,N) finds the coefficients of a polynomial
in XHAT = (X-MU(1))/MU(2) where MU(1) = mean(X) and MU(2) = std(X).
This centering and scaling transformation improves the numerical
properties of both the polynomial and the fitting algorithm.
Warning messages result if N is >= length(X),if X has repeated,or
nearly repeated,points,or if X might need centering and scaling.
See also POLY,POLYVAL,ROOTS.