how to sum rows within cell arrays?

6 views (last 30 days)
lucksBi
lucksBi on 4 Jan 2018
Commented: lucksBi on 4 Jan 2018
Hi all
how to sum rows within cell arrays?
array1 = {[4,3.3,2.5,0.71];[3.4,2,1,0.3]}
Result may look like this:
result = {[10.51];[6.7]}
  2 Comments
lucksBi
lucksBi on 4 Jan 2018
I have tried using sum
for x=1:8
result{x,1} = sum(array1{x,1});
end
But it gives following error:
Cell contents assignment to a non-cell array object.

Sign in to comment.

Accepted Answer

Birdman
Birdman on 4 Jan 2018
for i=1:length(array1)
result{i}=sum(array1{i},2);
end
  1 Comment
lucksBi
lucksBi on 4 Jan 2018
Yes problem solved. I have to clear result array and then apply this code.
Thanks alot.

Sign in to comment.

More Answers (0)

Categories

Find more on Multidimensional Arrays in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!