Dynamically Naming Structures
10 ビュー (過去 30 日間)
古いコメントを表示
I have a question that is proving very difficult to somebody with only two months of experience in Matlab. I want to create a series of nested structures, and need to have one level generate the variable dynamically. Here's my proposed structure:
pool.sub_X.trial_X.variables
pool: a structure containing all the data
sub_X: a structure for each of the subjects that were tested in an experiment. I would like X to be dynamically changed based on a numerical value it is given, resulting in a series of structures sub_1, sub_2, sub_3, etc. Total number of structures that will need to be created is unknown. (I was having trouble with this as it kept telling me I needed a cell array, and it wouldn't convert from a number to a cell.)
trial_X: similar to sub_X, based on the trial number it is given.
variables: this will several, predefined values that will be either numerical data or strings. I'm thinking the best way to do this would be to have a template structure that could easily be assigned to each trial.
I'm not sure if this all makes sense, but any pointers would be greatly appreciated. :)
0 件のコメント
回答 (1 件)
Walter Roberson
2012 年 3 月 16 日
Sure, see the dynamic field names part of this description:
0 件のコメント
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!