MSE and RMSE of a matrix

23 次查看(过去 30 天)
Sadiq Akbar
Sadiq Akbar 2020-10-3
评论: KSSV 2020-10-4
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 个评论
Sadiq Akbar
Sadiq Akbar 2020-10-3
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 ')

请先登录,再进行评论。

回答(1 个)

KSSV
KSSV 2020-10-3
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 个评论
Sadiq Akbar
Sadiq Akbar 2020-10-3
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 2020-10-4
Check the sizes of t , MSE.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by