naming a structure
Show older comments
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?
Accepted Answer
More Answers (1)
Walter Roberson
on 22 Feb 2012
2 votes
4 Comments
Richard
on 23 Feb 2012
Walter Roberson
on 23 Feb 2012
Don't do that. Use a master structure name and put your dynamic names all at a level underneath that.
Richard
on 23 Feb 2012
Kevin Holst
on 23 Feb 2012
I like this approach, and will be suggesting it in the future. Much safer, clearer, and cleaner.
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!