Recursively check fields of a structure exist

Check fields of a structure exist at any depth. Can also check multiple field branches at any depth.
ダウンロード: 670
更新 2010/7/22

ライセンスの表示

This function will return true if the first input structure contains the field in the second input string and in turn that field has the field given in the third input string and so on. This allows A.b.c = 2; to be checked as:
isfieldRecursive(A,'b','c')
ans =
1
Which would return false if either b is not a field of A or c is not a field of a.b

The other functionality of this function is that the existence of multiple fields at any depth can be determined by replacing a string input with a cell array of strings. e.g. A.b.c = 2;A.d.c = 2;
isfieldRecursive(A,{'b','d'},'c')
ans =
1
Which would have returned false if A did not have either field b or field d and those fields in turn did not have a field c.

引用

Matthew Arthington (2024). Recursively check fields of a structure exist (https://www.mathworks.com/matlabcentral/fileexchange/28142-recursively-check-fields-of-a-structure-exist), MATLAB Central File Exchange. 取得済み .

MATLAB リリースの互換性
作成: R2008b
すべてのリリースと互換性あり
プラットフォームの互換性
Windows macOS Linux
カテゴリ
Help Center および MATLAB AnswersCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!
バージョン 公開済み リリース ノート
1.1.0.0

Improved the summary text

1.0.0.0