Borrar filtros
Borrar filtros

I want to plot RMSE from mat file but it gives error

22 visualizaciones (últimos 30 días)
Sadiq Akbar
Sadiq Akbar el 13 de Jul. de 2024 a las 9:04
Comentada: Star Strider el 13 de Jul. de 2024 a las 13:27
When I run the m file, it gives me he following error:
Operator '-' is not supported for operands of type 'cell'.
Error in RMSE_Plot (line 5)
MSE = mean((u-two).^2,2);
>>

Respuesta aceptada

Star Strider
Star Strider el 13 de Jul. de 2024 a las 13:08
One option is to use the cellfun function (keeping ‘two’ as a cell array). The other option is to use the cell2mat function to convert ‘two’ to a numeric array.
I use cellfun here —
clear;clc
LD = load('3sn_Varying.mat');
u = LD.u;
two = LD.two;
[m,n] = size(two);
MSE = cellfun(@(x)mean((u-x).^2,2), two);
RMSE = sqrt(MSE);
%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Arrange in descending order
%%%%%%%%%%%%%%%%%%%%%%%%%%%
MSE=sort(MSE,'descend');
RMSE=sort(RMSE,'descend');
bestRMSE=min(RMSE)
bestRMSE = 6.5125e-05
%%%%%%%%%%%%%%%%%%%%
% Plotting RMSE
%%%%%%%%%%%%%%%%%%%%
figure
x=1:m;
semilogy(x,RMSE,'linewidth',2);
xlabel('\bf Independent Runs')
ylabel('\bf RMSE')
title('\bf RMSE vs Runs');
.
  2 comentarios
Sadiq Akbar
Sadiq Akbar el 13 de Jul. de 2024 a las 13:24
Thanks a lot. Each time your explanation clears everything to me.
Star Strider
Star Strider el 13 de Jul. de 2024 a las 13:27
As always, my pleasure!
I very much appreciate your compliment!

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by