Trying to index rows with specific values in two different columns (order matters) - similar to coordinates.
Show older comments
Hi all,
I'm pretty new to matlab, and need some help with indexing. What I'm trying to do is index all the rows that correspond to each of these coordinates: all the rows with 00 together, all the rows with 01 together, all the rows with 10 together, and all the rows with 11 together. Here is an example of the data I'm working with:
[visual_search 0 0; visual_search 1 0; visual_search 0 0; visual_search 1 0; visual_search 0 1; visual_search 1 1; visual_search 1 1; visual_search 0 1]
The first column is the name of the training task, and the following two columns are sort of like coordinates of an exercise grid, indicating the level (i.e. For a given exercise, there are various stages. Each stage typically consists of 4 levels, which are organized in a 2x2 grid). These "coordinates" begin at zero - 00 is top left, 01 top right, 10 bottom left, 11 bottom right. Therefore, the order of these values is important.
Any suggestions would be greatly appreciated!
Cheers, Sean C.
Answers (1)
Azzi Abdelmalek
on 30 Sep 2013
x={'visual_search' 0 0
'visual_search' 1 0
'visual_search' 0 0
'visual_search' 1 0
'visual_search' 0 1
'visual_search' 1 1
'visual_search' 1 1
'visual_search' 0 1}
data=cell2mat(x(:,2:3));
[a,b,c]=unique(data,'rows','stable');
out=arrayfun(@(x) find(ismember(data,a(x,:),'rows')),1:numel(b),'un',0);
display(a)
celldisp(out)
Categories
Find more on Polar Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!