## sum the elements in the cell array

Asked by Gopalakrishnan venkatesan

### Gopalakrishnan venkatesan (view profile)

on 6 Nov 2015
Latest activity Commented on by the cyclist

### the cyclist (view profile)

on 6 Nov 2015
Accepted Answer by the cyclist

### the cyclist (view profile)

a = { 1 2 3; 4 5 6; 7 8 9}
How to use the cellfun to sum the element row wise?

### the cyclist (view profile)

Answer by the cyclist

### the cyclist (view profile)

on 6 Nov 2015

Is there a specific reason you are using a cell array? This is easy with a numeric array:
a = [ 1 2 3; 4 5 6; 7 8 9 ];
sum(a,1) % Sum down columns
sum(a,2) % Sum across rows

Gopalakrishnan venkatesan

### Gopalakrishnan venkatesan (view profile)

on 6 Nov 2015
elements are in the cell ....... i dont want to convert cell2mat..... it works only for matrix
the cyclist

### the cyclist (view profile)

on 6 Nov 2015
Well you have to tell MATLAB somehow that the content of the cell are a numeric variable that can be summed, otherwise it could try to sum the cell array
a = {'red','donald trump',-Inf}
If the data are already in a cell array, then I don't think there is a better way than cell2mat to do this conversion.