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
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.
Best Answer