Effacer les filtres
Effacer les filtres

Indexing cell arrays with strings

3 vues (au cours des 30 derniers jours)
yuval
yuval le 27 Mai 2020
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

Réponses (0)

Catégories

En savoir plus sur Structures dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by