Finding R^2 without using the R^2, SUM or AVG commands

1 view (last 30 days)
Hi,
I have to write a script designed to find R^2 that doesn't use the R^2, SUM or AVG commands. I've written my script, but the answer is slightly out, and I was wondering if anyone might be able to point out any visible mistakes that I might have made in my script.
Please bear in mind that I'm incredibly new to MATLAB - I'm sure there are either loads of mistakes or I haven't provided you with enough information to see them. But I'm desperate!
Thanks so much in advance

Accepted Answer

Star Strider
Star Strider on 19 Mar 2014
I didn’t run your code, but I see two problems that might give erroneous results:
SSerrArray1 = SSerrArray(b) ;
and
SStotArray1 = SStotArray(c) ;
The problem is that these set SSerrArray1 and SStotArray1 to the last entry in their respective vectors, not the entire vector. (The loop indices b and c remain defined at their last values in the workspace until you change them.)
That means that in your code, SSerr becomes length(ydata)*SSerrArray1 and SSTot becomes length(ydata)*SStotArray1.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!