could anyone help me how to compute the mean square error between two cell.

조회 수: 1 (최근 30일)
I am having two cell A and B in the attached data.mat.
I want to compute the mean square error between A and B in data.mat.
Could anyone please help me on this.
  댓글 수: 2
Yazan
Yazan 2021년 7월 17일
How are you defining the MSE for your data? Each cell of A and B is a N-by-2 vector.
jaah navi
jaah navi 2021년 7월 17일
Here, both A and B has the same N-by-2 vector, for example
A{1,1}
1 2
1 1
1 1
1 1
1 2
1 1
1 2
1 2
1 2
1 2
B{1,1}
1 1
1 2
1 1
1 1
1 1
1 1
1 2
1 2
1 2
1 1
So first column of A needs to get subtracted with first column of B denoted by C and second column of A needs to get subtracted with second column of B denoted by D. Then I need to find the difference between C and D, square it and add all the rows and divide it by the 10.

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2021년 7월 17일
cellfun(@(a,b) sqrt(sum(a(:)-b(:)).^2))
You had the wrong definition of mean square error.
  댓글 수: 10
jaah navi
jaah navi 2021년 7월 18일
i am getting error stating Undefined operator '-' for input arguments of type 'cell'.
Walter Roberson
Walter Roberson 2021년 7월 18일
Please show the output of the following:
cellfun(@(a)string(class(a)), A)
cellfun(@(a)string(class(a)), B)
I suspect your A and B are not cell array of double like you indicate here. Judging by some of your other posts, I suspect that you have a mix, that some of the entries are double and others are cell.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

jaah navi
jaah navi 2021년 7월 18일
Anyhow i managed to get the partial output as required using the following commands for my data.mat as attached.
C=cellfun(@minus,A,B,'UniformOutput',false);
D=cellfun(@(x) sum((x(:,1)-x(:,2)).^2)/10,C,'UniformOutput',false)
Now I want to sum up all the rows of D and divide it by 5.
Could you please help me on this.
  댓글 수: 5

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by