MSE and RMSE of vector and Matrix

조회 수: 5 (최근 30일)
Sadiq Akbar
Sadiq Akbar 2022년 10월 11일
댓글: Sadiq Akbar 2022년 10월 12일
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')

채택된 답변

DGM
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')
  댓글 수: 1
Sadiq Akbar
Sadiq Akbar 2022년 10월 12일
Thanks a lot for your help.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 NaNs에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by