Save error R² of an interpolation curve in variable

조회 수: 1 (최근 30일)
Mepe
Mepe 2020년 3월 12일
편집: John D'Errico 2020년 3월 12일
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