Find index of all (non-unique) elements in a cell array as they appear in a second (sorted and unique) cell array
A = {'A'; 'E'; 'A'; 'F'}; B = {'A';'B';'C';'D';'E'; 'F'}; I am trying to get for each string in cell array A , the index that matches that string in cell array B . A will have repeated values, B will not. find(ismember(B, A) == 1) outputs 1 5 6 but I want to get 1 5 1 6 preferably in a one liner. I can't use strcmp instead of ismember either as the vectors are different sizes. The vectors will actually contain date strings, and I need the index not a logical index matrix, I'm interested in the number not to use it for indexing. How do I do it? You flip the arguments to ismember , and you use