RMSE between two variables
Show older comments
Hello, I am really new at matlab. I am trying to create a sub-function that has an input of two vectors and output the RMSE between the values in the vectors. Anyone can help? I would love to understand step by step. thanks to anybody that can help!!
Accepted Answer
More Answers (1)
Rik
on 5 Mar 2018
There are two main ways of doing this: an anonymous function and a 'normal' function.
%anonymous function:
calculate_RMSE=@(a,b) sqrt(mean((a(:)-b(:)).^2));
%normal function (save this in calc_RMSE.m)
function rmse=calc_RMSE(a,b)
rmse=sqrt(mean((a(:)-b(:)).^2));
The two function can be used in the exact same way. The second option provides more options for checking if the input is correct.
1 Comment
silvia battistella
on 6 Mar 2018
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!