naming a structure
显示 更早的评论
clear all
FName = {'Data1','Data2','Data3'};
data1 = [rand(32,1),rand(32,1),rand(32,1)];
NewName = {'Location1'};
Location1 = struct('Data1',data1)
From this example how is it possible to adapt the script so that instead of typing 'Location1' as the name of the structure, can that be defined from 'NewName' i.e. defining the name of the structure from a pre-defined string?
采纳的回答
更多回答(1 个)
Walter Roberson
2012-2-22
2 个投票
4 个评论
Richard
2012-2-23
Walter Roberson
2012-2-23
Don't do that. Use a master structure name and put your dynamic names all at a level underneath that.
Richard
2012-2-23
Kevin Holst
2012-2-23
I like this approach, and will be suggesting it in the future. Much safer, clearer, and cleaner.
类别
在 帮助中心 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!