MSE and RMSE of vector and Matrix

7 visualizzazioni (ultimi 30 giorni)
Sadiq Akbar
Sadiq Akbar il 11 Ott 2022
Commentato: Sadiq Akbar il 12 Ott 2022
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')

Risposta accettata

DGM
DGM il 11 Ott 2022
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')

Più risposte (0)

Categorie

Scopri di più su Matrices and Arrays in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by