Find with an indexed struc

3 ビュー (過去 30 日間)
AwedBy Matlab
AwedBy Matlab 2014 年 7 月 31 日
コメント済み: AwedBy Matlab 2014 年 8 月 1 日
I have a struc M whose size is (88,1)
If for instance I type M(46,1).acc I get ans = 0
I typed find(M(:,1).acc==0) to find the rows where the acc field is zero, but got the error Error using == : Too many input arguments.
Any help? Thanks!!

採用された回答

Image Analyst
Image Analyst 2014 年 7 月 31 日
Try
find([M(:,1).acc]==0)
  1 件のコメント
AwedBy Matlab
AwedBy Matlab 2014 年 7 月 31 日
Thanks!

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

その他の回答 (1 件)

Ben11
Ben11 2014 年 7 月 31 日
編集済み: Ben11 2014 年 7 月 31 日
It might not be the most elegant but I think it would solve your problem
Indices = cellfun(@(x) x == 0,struct2cell(M)) % you get a logical array where 0's have an index of 1
there is probably a more clever way to do it though.
  3 件のコメント
Ben11
Ben11 2014 年 7 月 31 日
You're welcome! I prefer Image Analyst's answer though :)
AwedBy Matlab
AwedBy Matlab 2014 年 8 月 1 日
me too in this case :p

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

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by