how to sum rows within cell arrays?

6 vues (au cours des 30 derniers jours)
lucksBi
lucksBi le 4 Jan 2018
Commenté : lucksBi le 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 commentaires
lucksBi
lucksBi le 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 le 4 Jan 2018
Check my answer.

Connectez-vous pour commenter.

Réponse acceptée

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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Multidimensional Arrays dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by