Azzera filtri
Azzera filtri

sum of array in structure.

3 visualizzazioni (ultimi 30 giorni)
Pramit Biswas
Pramit Biswas il 3 Gen 2018
Commentato: Elias Gule il 16 Gen 2018
uC = zeros(1,length(X));
for loop1 = 1:length(X)
uC(loop1) = sum(X(loop1).Y);
end
Any other/proper/quick way to do this? (Note: length of all X.Y is not same.)

Risposta accettata

Elias Gule
Elias Gule il 3 Gen 2018
try this.
uC = arrayfun(@(v) sum(v.Y),x)
  4 Commenti
Pramit Biswas
Pramit Biswas il 3 Gen 2018
oops!!! Is this function only to reduce code? Any other ways?
Elias Gule
Elias Gule il 16 Gen 2018
Yep!

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Structures in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by