Indexing cell arrays with strings

1 回表示 (過去 30 日間)
yuval
yuval 2020 年 5 月 27 日
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 件)

カテゴリ

Help Center および File ExchangeStructures についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by