Obtaining elements of a vector from a nested Cell Array
1 view (last 30 days)
Show older comments
I have a cell array (see below)
ParameterCellArray{14,1}={'a,[50,100,180],'pe'}; %
ParameterCellArray{14,2}={'b',0.2:0.2:1,'co'};
ParameterCellArray{14,3}={'c',[1 1 1 1 0.2 0.4 0.6 0.7 0.8 0.9 1],'co'};
ParameterCellArray{14,4}={'d',[1 1 1 1 0.2 0.4 0.6], 'co'};
ParameterCellArray{14,5}={'e',130,'co'};
ParameterCellArray{14,6}={'f',[2 10 11 12],'pe'};
I would like to collect all the vectors i.e ParameterCellArray{14,1}{2} where ParameterCellArray{14,1}{3}='pe' in a new cell array which has only the numerical values. I can do this with a for loop but I am sure there is an easier way to do this. However ParameterCellArray{14,:}{2} gives me an error 'Bad Cell reference' Any help would be greatly appreciated.
Thanks a lot..
0 Comments
Answers (1)
Iain
on 4 Jun 2013
Try a three dimensional cell array
ParameterCellArray{row, column, deep}
deep = 1, to get the 'a','b', etc., deep = 2 to get the numbers, deep = 3 to get the 'pe'/'co'.
0 Comments
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!