Indexing cell arrays with strings
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Structures finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!