How to calculate r squared from a given cos regression model

1 回表示 (過去 30 日間)
Rey Li
Rey Li 2020 年 3 月 16 日
コメント済み: Rey Li 2020 年 3 月 17 日
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

採用された回答

Rik
Rik 2020 年 3 月 16 日
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 件のコメント
Rik
Rik 2020 年 3 月 17 日
Hint: start your looking with the fit function.
Rey Li
Rey Li 2020 年 3 月 17 日
thanks :) i've known how to do it now

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLinear and Nonlinear Regression についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by