Filter löschen
Filter löschen

how to sum rows within cell arrays?

9 Ansichten (letzte 30 Tage)
lucksBi
lucksBi am 4 Jan. 2018
Kommentiert: lucksBi am 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 Kommentare
lucksBi
lucksBi am 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.
Birdman
Birdman am 4 Jan. 2018
Check my answer.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by