フィルターのクリア

How to use structure variable names in for loop

6 ビュー (過去 30 日間)
jinang patel
jinang patel 2020 年 4 月 28 日
コメント済み: Tommy 2020 年 4 月 28 日
Hello,
I have a .mat file from a source containg structures with variable names as A,B,C etc.
I'm loading those to my workspace,creating a array for variable names and want to access the structures in a for loop. Error Dot indexing is not supported for variables of this type.
----------------------------------------------------------------------------
Structure names={'A','B','C'}
for i=1:3
output= Structure names(i).fieldname
end
  5 件のコメント
jinang patel
jinang patel 2020 年 4 月 28 日
Great that works!! Thanks
Tommy
Tommy 2020 年 4 月 28 日
Fantastic! Trying to break a habit of answering questions in the comments...

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

採用された回答

Tommy
Tommy 2020 年 4 月 28 日
Loop through the structures instead of their names:
Structure={A,B,C,..,n};
for i=1:numel(Structure)
output= Structure{i}.fieldname;
end

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