Info

此问题已关闭。 请重新打开它进行编辑或回答。

How can I do loop for struct data?

1 次查看(过去 30 天)
Riyadh Muttaleb
Riyadh Muttaleb 2016-4-18
关闭: MATLAB Answer Bot 2021-8-20
I have a data set that consist of a structure , example: data (1x10 struct with 1 field) How can I do loop to read all these data? I want to be able to do a calculation on a specific measurements of each field. Thanks

回答(2 个)

Azzi Abdelmalek
Azzi Abdelmalek 2016-4-18
a=struct('f',num2cell(1:10))
out=[a.f]
  6 个评论
Azzi Abdelmalek
Azzi Abdelmalek 2016-4-20
suppose you have this matrix
A=[1 2;3 4;5 6]
What operation you want to apply?

Walter Roberson
Walter Roberson 2016-4-19
Example:
arrayfun(@(IDX) mean(YourStructArray(IDX).TheField(:)), 1:numel(YourStructArray))

此问题已关闭。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by