sum of array in structure.

3 次查看(过去 30 天)
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.)

采纳的回答

Elias Gule
Elias Gule 2018-1-3
try this.
uC = arrayfun(@(v) sum(v.Y),x)
  4 个评论
Pramit Biswas
Pramit Biswas 2018-1-3
oops!!! Is this function only to reduce code? Any other ways?

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Structures 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by