Suppose all elements in array1 are contained in array2, now we want to get the indices of array1's elements in array2.
Here is a simple and neat solution, using Matlab's arrayfun function, which applies a function to each element of an array.
ans =
4 2
Read More
Here is a simple and neat solution, using Matlab's arrayfun function, which applies a function to each element of an array.
array1=[1,6,2,3,7];
array2=[3,6];
arrayfun(@(x)find(array1==x,1),array2)
The output is: ans =
4 2