Find indexes in cell array
조회 수: 13 (최근 30일)
이전 댓글 표시
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
채택된 답변
추가 답변 (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!