Save error R² of an interpolation curve in variable

1 次查看(过去 30 天)
A polynomial compensation curve with its coefficients is determined at various measuring points.
myfit=fit(x,y,'poly2');
A=myfit.p1
B=myfit.p2
C_=myfit.p3
Now i still need the error of this interpolation (R²). Can it also be read and stored in a variable?

采纳的回答

John D'Errico
John D'Errico 2020-3-12
编辑:John D'Errico 2020-3-12
You misunderstand the idea of interpolation, confusing it with approximation.
R^2 is identically 1 for an interpolation, since interpolation is defined so that it always predicts the original data. So an interpolating spline has always zero residuals in theory, therefore, R^2 == 1.
Anyway, just read the help for fit!!!!!!!
x = rand(10,1);
y = randn(size(x));
[mdl,G] = fit(x,y,'poly2')
y = randn(size(x));
[mdl,G] = fit(x,y,'poly2')
mdl =
Linear model Poly2:
mdl(x) = p1*x^2 + p2*x + p3
Coefficients (with 95% confidence bounds):
p1 = 1.399 (-3.992, 6.791)
p2 = -0.1758 (-5.699, 5.347)
p3 = -0.4521 (-1.34, 0.4359)
G =
struct with fields:
sse: 2.72060725180258
rsquare: 0.468192584870819
dfe: 7
adjrsquare: 0.316247609119625
rmse: 0.623424557447764
As you can see, G has fields that answer your question: G.rsquare, and G.adjrsquare.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interpolation 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by