Indexing cell arrays with strings
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Structures 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!