How to use structure variable names in for loop
7 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Structures 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!