how to find the difference between first column and second column in a cell array

I am a having cell
C=5x1 cell
which contains
10x2 double
10x2 double
10x2 double
10x2 double
10x2 double
I need to find the difference between first and second column of C. Could anyone please help me on it.

 채택된 답변

cellfun(@(x) x(:,1)-x(:,2),C,'UniformOutput',false)

댓글 수: 5

ok. As a next step I calculated the sum using
cellfun(@sum, C,'UniformOutput',false)
Now I want to divide by 10.
So i tried using
cellfun(@sum, C,'UniformOutput',false)/10
but i am getting error stating Undefined operator '/' for input arguments of type 'cell'.
Could you please help me to overcome the error.
If you do the sum and then divide by 10, so I guess you want to calculate the mean and you can use the following directly without doing the sum
cellfun(@mean,previous_result,'UniformOutput',false)
Sorry, I made a mistake. First I need to square it and then sum it together and divide by 10. Could you please help me on it.
I used the command
D=cellfun(@(x) sum((x(:,1)-x(:,2)).^2)/10,C,'UniformOutput',false)
Now I want to sum D and divide by 5.
Could you please help me on this.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Type Conversion에 대해 자세히 알아보기

태그

질문:

2021년 7월 18일

댓글:

2021년 7월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by