フィルターのクリア

MSE and RMSE of vector and Matrix

9 ビュー (過去 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 Center および File ExchangeNaNs についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by