I am trying to find the indices of elements in a vector that correspond to another vector, preferably without using loops. For example, my input might be:
DJ
Divakar's answer is the way to go. But in case you want to do it more manually:
[~, Output] = max(bsxfun(@eq, DJiSet(:).', JiSet(:)), [], 1);
This finds the first occurrence if there are more than one.
If the values in DJiSet were not guaranteed to be present in JiSet, you could use a small modification:
[val, Output] = max(bsxfun(@eq, DJiSet(:).', JiSet(:))); %'
Output(~val) = 0; %// 0 indicates "not found"