how to sum rows within cell arrays?

9 次查看(过去 30 天)
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 个评论
lucksBi
lucksBi 2018-1-4
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.

请先登录,再进行评论。

采纳的回答

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

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by