MSE and RMSE of vector and Matrix
4 次查看(过去 30 天)
显示 更早的评论
I have a vector u=[-30 0 41.721]; and a matrix two=rand(100,3); I want to find the error between the two, square of that error, mean square error and root mean square error for all 100 values. How can I find them. After that I want to plot the error vs ii=1:100, square of error vs ii=1:100 and mean square error vs ii=1:100 and root mean square error vs ii=1:100. I tried like this but it gives error:
clear all
clc
u=[-30 0 41.721];
two=rand(100,3);
[m,n] = size(two) ;
Error = abs(u-two) ;
square_Error = abs(u-two).^2 ;
for ii=1:m
MSE(ii) = norm((u-two(ii,:)).^2/m); %MSE = (u-two).^2/m ;
RMSE(ii) = sqrt((u - two(ii,:)).^2/m);
end
MSE=MSE';
RMSE=RMSE';
plot(ii,MSE,'r',ii,RMSE,'g')
0 个评论
采纳的回答
DGM
2022-10-11
You're not taking the mean of the row vectors, so the RHS of the assignment is still a vector. Try this:
u = [-30 0 41.721];
two = rand(100,3);
[m,n] = size(two);
MSE = mean((u-two).^2,2);
RMSE = sqrt(MSE);
x = 1:m;
plot(x,MSE,'r',x,RMSE,'g')
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 NaNs 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!