Find indexes in cell array
12 views (last 30 days)
Show older comments
Hi all,
i have 2 arrays one containing all my values (even duplicates) and one containing the unique elements.
My goal is to find the index of my values based on the index of the unique elements
R = [2 ,1 , 1 , 2 , 4 , [1,3] , [1,3] , 4 , [1,3] , [2,5] , [2,5] , 4]
C= [2 , 1 , 4 , [1,3] , [2,5]]
Vectors [1,3] should be treated as 1 unique element, not as 1 and 3
If its easier we can work with letters
R1=['2B' , '1A' , '1A' , '2B' , '1D' , '1A+1C' ,'1A+1C' , '1D' , '1A+1C' , '1B+1E' , '1B+1E', '1D']
C1=['1A' , '2B' , '1A+1C' , '1D' , '1B+1E']
In both cases i expect to get an array
idx = [2, 1, 1, 2, 4, 3, 3, 4, 3, 5, 5, 4]
The order is important, idx should be in the same order of the original R/R1 vector.
I tried find and a bit of arrayfun but couldnt get it to work
Thank you so much in advance
0 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Structures 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!