How to calculate mean square error between points?

Hello everyone. Here I want to calculate the mean square error between the blue dots and the red dot. I'm putting the files. I can't form in my head how to do it. I would be glad if you help.
scatter(reshape(x_T_est1(all(x_T_est1,2),:), [1,numel(x_T_est1(all(x_T_est1,2),:))]), reshape(y_T_est1(all(y_T_est1,2),:), [1,numel(y_T_est1(all(y_T_est1,2),:))]), 'b', 'x'); hold on;
scatter(x_T, y_T, 'r', 'filled');

 Respuesta aceptada

David Hill
David Hill el 2 de Mzo. de 2022
Editada: David Hill el 2 de Mzo. de 2022
load('x_T.mat');load('x_T_est1.mat');load('y_T.mat');load('y_T_est1.mat');
b=[reshape(x_T_est1(all(x_T_est1,2),:),[1,numel(x_T_est1(all(x_T_est1,2),:))]);...
reshape(y_T_est1(all(y_T_est1,2),:),[1,numel(y_T_est1(all(y_T_est1,2),:))])]';
b=b(~isnan(b(:,1))&~isnan(b(:,2)),:);%you have some NANs in your arrays.
r=[x_T,y_T];
meanSquaredError=sum((b-r).^2)/length(b);

5 comentarios

I could not run this code correctly. Could you help?
b=[reshape(x_T_est1(all(x_T_est1,2),:);[1,numel(x_T_est1(all(x_T_est1,2),:))]),...
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched
delimiters.
David Hill
David Hill el 2 de Mzo. de 2022
Changed it above. Just want b to be an array of your points [x,y].
I also included the file. I can't write them this way as a single point. If you know a way please let me know
David Hill
David Hill el 2 de Mzo. de 2022
If your scatter plot is working, then the above code should work. I tried in on your attached files (except y_T_est1 not provide, so I set it equal to x_T_est1) and it worked. Not sure what you want to do with the nan values.
thank you

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.

Preguntada:

el 2 de Mzo. de 2022

Comentada:

el 6 de Mzo. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by