how can i write function with the picture which i attached to the question?

1 view (last 30 days)
hey people
have a good time
i have a problem over the function which i attached to this Question.
i would like to write the function which take 2 variables (e.g. t and o)
and compute rmse and r^2 coefficient
can you help me out over this problem?
  2 Comments
Geoff Hayes
Geoff Hayes on 23 Jun 2021
hadi - what have you tried so far? Please describe what you have attempted and discuss what problem or errors you are experiencing with your code.
hadi me
hadi me on 23 Jun 2021
I've tried 2 version of this problem
one of that, is:
function [term1 , term2] = stat(o , t)
term1=...
term2=...
end
but it didn't work
I would like to compute the error from 2 rows of input data
I have problem with matlab code.
can you help me?

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 23 Jun 2021
Here's some help:
Also check out the sum() and sqrt() functions. To square, use the caret:
term1 = sum(O) ^ 2
Multiplication is * and division is /. Not hard. Just take it one term at a time:
term1 = ....
term2 = ....
denominator = ....
rSquared = ( (term1 - term2 * term3) / denominator) ^2
Or you can simply use the built in functions for mse() and corrcoef().
  1 Comment
Image Analyst
Image Analyst on 23 Jun 2021
Sure we can help you but all you gave was a partial snippet of one of your attempts, which was just a partial snippet of my answer above:
function [term1 , term2] = stat(o , t)
term1=...
term2=...
end
It seems you forgot to upload your entire two code attempts so how can I comment on them? So I guess my answer stands as-is until you upload your code. Come on, you can do it, you're a smart engineer. It sounds like homework, and if so I'm sure your instructor didn't just say "See if someone in the Answers forum can do your homework problem for you."

Sign in to comment.

Categories

Find more on Get Started with MATLAB 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!