MATLAB Answers

sum of array in structure.

13 views (last 30 days)
Pramit Biswas
Pramit Biswas on 3 Jan 2018
Commented: Elias Gule on 16 Jan 2018
uC = zeros(1,length(X));
for loop1 = 1:length(X)
uC(loop1) = sum(X(loop1).Y);
Any other/proper/quick way to do this? (Note: length of all X.Y is not same.)

Accepted Answer

Elias Gule
Elias Gule on 3 Jan 2018
try this.
uC = arrayfun(@(v) sum(v.Y),x)

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!