MSE and RMSE of a matrix

23 visualizaciones (últimos 30 días)
Sadiq Akbar
Sadiq Akbar el 3 de Oct. de 2020
Comentada: KSSV el 4 de Oct. de 2020
I have a reference vector u of size 1x8. In this matrix the 1st four columns are voltage readings and last four columns are current readings.i.e.
u=[v1 v2 v3 v4 i1 i2 i3 i4];
Likewise I have another set of 100 vectors.The size of each of them is also 1x8. The nature of those vectors is also same like u i.e. 1st four columns are voltages and last four columns are currents in each of them. If I write those 100 vectors in a matrix called two. The size of the matrix two becomes 100x8. Now I find the difference between each of the row of matrix two and u. i.e.This gives me another matrix Error of size 100x8. i.e.
Error(nn,:)= abs(u(1,:)-two(nn,:));
Now I want to find the MSE and RMSE of this matrix Error and plot both the MSE and RMSE.
  1 comentario
Sadiq Akbar
Sadiq Akbar el 3 de Oct. de 2020
This is my code. Is this correct?
u=[1 1.5 2 2.5 150 20 60 110];
two=randi(100,8);
for nn=1:100
Error(nn,:)= abs(u(1,:)-two(nn,:));
Error4sn0(nn)=abs(Error(nn,:)).^2; % Sqaured Error of Four sources
MSE4sn0(nn) = sum(Error4sn0(nn,:))/8;
end
MSE4sn0=MSE4sn0';
MSE4sn0=sort(MSE4sn0,'descend');
t=1:100;
semilogy(t,smooth(MSE4sn0),'linewidth',2)
xlabel('Runs')
ylabel('MSE')
title('MSE of All ')

Iniciar sesión para comentar.

Respuestas (1)

KSSV
KSSV el 3 de Oct. de 2020
If yt and ye are the column vectors of theory and experimental values. You can get MSE, RMSE using:
e = (ye - yt) % Errors
suqre_e = (ye - yt).^2 % Squared Error
MSE = mean((ye - yt).^2) % Mean Squared Error
RMSE = sqrt(mean((ye - yt).^2)); % Root Mean Squared Error
  8 comentarios
Sadiq Akbar
Sadiq Akbar el 3 de Oct. de 2020
Thank you very much for your help. I used the plot command directly, but it gave me the following error:
Error using plot
Vectors must be the same length.
Error in MSERMSEbyKSSV (line 12)
plot(t,MSE,t,RMSE);
KSSV
KSSV el 4 de Oct. de 2020
Check the sizes of t , MSE.

Iniciar sesión para comentar.

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by