フィルターのクリア

Calling a Field of a Struct by a Pre-defined String Variable

1 回表示 (過去 30 日間)
Rightia Rollmann
Rightia Rollmann 2017 年 2 月 7 日
コメント済み: Stephen23 2017 年 2 月 7 日
I want to call a field of a struct by a string variable named like that field, but I receive the error “Reference to non-existent field …”. How can I solve this problem? I mean how can I define a name of a field with a string variable and then add this string variable to struct to call the field?
A.B = 'B1'; % Assign the value B1 to field B
C = 'B' % Assign the value B to variable C
A.C % I receive the error “Reference to non-existent field 'C'.”

採用された回答

Guillaume
Guillaume 2017 年 2 月 7 日

その他の回答 (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