How do I calculate mean absolute error?
조회 수: 75 (최근 30일)
이전 댓글 표시
x_T = 0.3; y_T = 0.3;
A_T = 38:0.1:45;
for i_A = 1:length(A_T)
for i_file = meas
error_1(i_file,:) = sqrt((x_T_est1(i_file,:) - x_T).^2 + (y_T_est1(i_file,:) - y_T).^2);
end
end
Hello everyone. I am sharing part of my code. I am also attaching the necessary files.
What I want to do is adapt this formula. The number n is the size of the matrix x_T_est1 an y_T_est1. So 28x5=140. n = 140.
I want to calculate MAE for all numbers in matrix x_T_est1. But I want to save it in a matrix of length i_A.
In summary, subtract the x_T and y_T values for all the elements in the x_T_est1 matrix, take the square root, and add the value for all the elements. Then divide by 140. This result is a number. For example, let the result be the number A. Let it record this number A as the length of the matrix A_T. So the result vector and the vector A_T will be the same size. Result matris = A, A, A...(1x71). Vector A_T is a vector of length 1x71.
You can change the code however you want.
댓글 수: 0
채택된 답변
David Hill
2022년 4월 6일
편집: David Hill
2022년 4월 7일
x_T = 0.3; y_T = 0.3;
%A_T = 38:0.1:45; have no idea what you are doing with A_T (it is not in your equation)
[x,y]=meshgrid(x_T_est1,y_T_est1);
mae=sum(sqrt((x_T-x).^2+(y_T-y).^2)./numel(x),'all');%this is the mae for the x_T and y_T values listed
댓글 수: 2
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!