How to calculate r squared from a given cos regression model

1 Ansicht (letzte 30 Tage)
Rey Li
Rey Li am 16 Mär. 2020
Kommentiert: Rey Li am 17 Mär. 2020
Hi i am a new learner, i got confused how can i calculate like this,
if there's two sets,
x = [0.0000 0.5236 1.0472 1.5708 2.0944 2.6180 3.1416]
y = [2.7600 -2.3902 1.3800 0.0000 -1.3800 2.3902 -2.7600]
and the given function, y = a cos(5x), find the r squared for this function

Akzeptierte Antwort

Rik
Rik am 16 Mär. 2020
y_fit = a cos(5*x)
err=y-y_fit;
SSres=sum(err.^2);
SStot=sum((y-mean(y)).^2);
rsq=1-(SSres./SStot);
  5 Kommentare
Rik
Rik am 17 Mär. 2020
Hint: start your looking with the fit function.
Rey Li
Rey Li am 17 Mär. 2020
thanks :) i've known how to do it now

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Linear and Nonlinear Regression finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by