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.

 Réponse acceptée

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

5 commentaires

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.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Data Type Identification dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by