Dynamically Naming Structures
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Walter Roberson
el 16 de Mzo. de 2012
Sure, see the dynamic field names part of this description:
0 comentarios
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!