Extracting common values and there indices from two waves

I have two waves of different dimensions. Both these have few overlapping/same values but at different locations .e.g., the 4th index of wave 1 might be the same as the 6th index of wave 2, etc.I am looking to extract these common values from 2 waves and also the indices where they lie on the larger waves. Do you have any suggestions on how can I do that? I tried functions like binary search or find value but they don’t seem to do the desired job

A surefire but slow way to do this is to loop over the smaller wave and check whether each point gives any result with FindValue applied on the larger wave. If V_value is different from -1 note both the position and the current search value in a separate result wave.

In reply to by chozo

You can use Extract with the /INDX flag, searching for each value in your smaller wave one at a time.

As an example, try this:

Function doStuff()
    Make/O/I myData = {1,4,6,2,4,3,2,6,5,2}
    Make/O/I mySearch = {4,2}
    Make/O/I/N=0 myResult
    variable i
    Make/FREE/I myTempResult
    for(i = 0; i < DimSize(mySearch, 0); i += 1)
        Extract/FREE/INDX myData, myTempResult, myData==mySearch[i]
        Concatenate  {myTempResult}, myResult

You can easily extend this to give the matching value as well.