[[y,,,,三角洲] = polyval(p,,,,X,,,,s)uses the optional output structures由。。。生产polyfitto generate error estimates.三角洲是an estimate of the standard error in predicting a future observation atX经过p((X)。
y= polyVal(p,,,,X,[],,亩)或者[[y,,,,三角洲] = polyval(p,,,,X,,,,s,,,,亩)使用可选输出亩由。。。生产polyfit中心和扩展数据。亩((1)是平均(x), 和亩((2)是std(x)。Using these values,polyval中心Xat zero and scales it to have unit standard deviation,
This centering and scaling transformation improves the numerical properties of the polynomial.
Fit a linear model to a set of data points and plot the results, including an estimate of a 95% prediction interval.
Create a few vectors of sample data points((X,,,,y)。利用polyfit为了将第一度多项式拟合到数据。指定两个输出以返回线性拟合以及误差估计结构的系数。
x = 1:100;y = -0.3*x + 2*randn(1,100);[p,s] = polyFit(x,y,1);
评估一级多项式拟合p在X。将误差估计结构指定为第三个输入,以便polyval计算估计的标准误差。的standard error estimate is returned in三角洲。
[y_fit,delta] = polyval(p,x,s);
Plot the original data, linear fit, and 95% prediction interval。
情节(x,y,'bo') 抓住上情节(x,y_fit,'r-')plot(x,y_fit+2*delta,'M--',x,y_fit-2*delta,'M--')title('Linear Fit of Data with 95% Prediction Interval')legend('Data',,,,“线性拟合”,,,,'95%的预测间隔')
利用polyfitwith three outputs to fit a 5th-degree polynomial using centering and scaling, which improves the numerical properties of the problem.polyfit中心数据年at 0 and scales it to have a standard deviation of 1, which avoids an ill-conditioned Vandermonde matrix in the fit calculation.
查询点,,,,specified as a vector.polyval评估多项式p在X并返回相应的函数值y。
Data Types:single|double 复杂的数字支持:万博1manbetxYes
s-误差估计结构 结构体
误差估计结构。该结构是从[[p,,,,s] = polyfit(x,y,n)that can be used to obtain error estimates.s包含以下字段:
场地
Description
r
Triangular factor from a QR decomposition of the Vandermonde matrix ofX
DF
Degrees of freedom
n或者mr
Norm of the residuals
如果the data iny是随机的,然后是对协方差矩阵的估计p是((rinv*Rinv')*normr^2/df,,,,whererinv是the inverse ofr。
亩-Centering and scaling values 两元素向量
中心和缩放值,指定为两元素向量。该向量是来自[[p,,,,s,,,,亩] = polyfit(x,y,n)that is used to improve the numerical properties of fitting and evaluating the polynomialp。的value亩((1)是平均(x), 和亩((2)是std(x)。的se values are used to center the query points inXat zero with unit standard deviation.