condition for structure class

1 回表示 (過去 30 日間)
ha ha
ha ha 2017 年 11 月 23 日
編集済み: ha ha 2017 年 11 月 26 日
Let's say:
A : 4x1 structure class
A= Field1 :[1000x1 double],
Field2 : [2x1 double],
Field3 : [5x1 double],
Field4 : [1x1 double]
A= Field1 : [1;2;3...;1000],
Field2 : [99;11],
Field3 : [44;11;33;88;66],
Field4 : [77]
Question: I wanna implement the condition as follow:
If ......[the length of each field in structure A < 5]......
........do.....s.thing.....
else
end
How can I write the condition :[the length of each field in structure A < 5] ?
Example:
length of field1= 1000
length of field2= 2
length of field3= 5
length of field4= 1

採用された回答

Walter Roberson
Walter Roberson 2017 年 11 月 24 日
arrayfun(@(S) all(structfun(@length, S) < 5), A)
  3 件のコメント
Walter Roberson
Walter Roberson 2017 年 11 月 24 日
arrayfun(@(S) structfun(@length, S), A, 'uniform', 0)
ha ha
ha ha 2017 年 11 月 24 日
Thank so much @Walter Roberson

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStructures についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by