Removing repeating values from waves

Is there a clean way to remove repeating values from waves? I have waves that sometimes have duplicates or triplicates of a number and I would like to keep only one instance. I have looked in the forum and manual but I haven't spotted anything like a function that may help in doing this. I was thinking of sorting and creating two lists to move numbers from one to the other after parsing through but any ideas are appreciated.
Just for clarification: You want unique INTEGERS in the wave (and not just zap consecutive occurrences)?

Maybe this could serve as a first idea (result is sorted):
make /N=6 test ={1,1,3,4,4,1}
make /N=10 hist // Probably needs to be adjusted to the minimum and maximum values of the wave
histogram /B={0,1,10} test, hist // here as well
hist= (hist==0) ? nan : p
wavetransform ZapNaNs hist


Beware of floats !

HJ
In IP7 you can use the FindDuplicates operation.

A.G.
WaveMetrics, Inc.
Here is my take on it. Zaps all repeating integers after the first one.

Invoke it like: thunk_zapnum(w_wave, 5), where w_wave is your wave, 5 is the number you want to zap.

function thunk_zapnum(w_wave, v_num)
    wave& w_wave //1d wave
    variable v_num
    variable i
   
    variable v_sz = dimsize(w_wave,0)
    make/o/n=(v_sz) w_ind = (w_wave == v_num) ? p : nan
    wavetransform/o zapnans, w_ind
   
    variable v_sz_ind = dimsize(w_ind,0)
    for (i=1; i<v_sz_ind; i+=1)
        w_wave[w_ind[i]] = nan
    endfor
    wavetransform/o zapnans, w_wave
   
end


best,
_sk
_sk wrote:
Here is my take on it. Zaps all repeating integers after the first one.
Invoke it like: thunk_zapnum(w_wave, 5)


The code is limited to Integer values and you would have to loop over a list of integers which you want to remove.

If you just wanted to remove a specific value from a wave it is simpler to execute:
MatrixOP/O aa=replace(w_wave,specificValue,NaN)
WaveTransform zapNaNs aa


Note that in this example specificValue is any real-value and strict equality is required, something that FindDuplicates handles via the Tolerance flag.

A.G.
Igor wrote:

..
MatrixOP/O aa=replace(w_wave,specificValue,NaN)
WaveTransform zapNaNs aa

..
A.G.


This will also remove the first instance of the duplicate integer, which I interpreted as a requirement of the poster. If this isn't the case, then, indeed, there is no need for looping through the indeces of the duplicate integer.

best,
_sk
_sk wrote:

This will also remove the first instance of the duplicate integer, which I interpreted as a requirement of the poster. If this isn't the case, then, indeed, there is no need for looping through the indeces of the duplicate integer.
_sk


You are absolutely right. It will remove all instances.