MATLAB Answers

How can i use 'sum' for a 'cell array'?

79 views (last 30 days)
masoud jiryaei
masoud jiryaei on 7 May 2019
Commented: masoud jiryaei on 10 May 2019
Hello
i have a cell array that i want to sum the coulmns ;
A={ 1x2 double , 1x2 double
1x2 double , 1x2 double
1x2 double , 1x2 double
1x2 double , 1x2 double }

Accepted Answer

KSSV
KSSV on 7 May 2019
A = cell(4,2) ;
for i = 1:4
for j = 1:2
A{i,j} = rand(1,2) ;
end
end
B = cellfun(@sum,A)
  1 Comment
masoud jiryaei
masoud jiryaei on 10 May 2019
Thank you so much;
It was usefull.

Sign in to comment.

More Answers (1)

Community Treasure Hunt

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

Start Hunting!