Indexing cell arrays with strings
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hello,
I find myself lately wanting to use something like a cell array whose indexes are strings, like a named list in R but multidimensional.
Say I have raw and processed data from 10 subjects recorded with Method A and Method B.
I would like to access my data as follows:
MyData{7,'RawData','MethodB'} = value
Alternatively, using struct array:
MyData(7,'RawData').MethodB = value
Of course it is arbitrary that ’RawData’ is an index and the MethodB is a field and it could have been the other way around.
I thought using a map container:
M = containers.Map;
M('RawData') = 1; M('ProcessedData') = 2;
M('MethodA') = 1; M('MethodB') = 2;
Then I could access my data using:
MyData{7,M('RawData'),M('MethodB')} = value
Since it is not a very neat solution, any better thoughts on this issue?
Thank you
0 comentarios
Respuestas (0)
Ver también
Categorías
Más información sobre Structures en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!