how to sum rows within cell arrays?

11 ビュー (過去 30 日間)
lucksBi
lucksBi 2018 年 1 月 4 日
コメント済み: lucksBi 2018 年 1 月 4 日
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 日
Check my answer.

サインインしてコメントする。

採用された回答

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 Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by