How to delete points in a large one-dimensional wave efficiently?

Hello,

I want to delete zero points in a large one-dimensional wave(almost 1e7 points). I run the program about 20min but it still not come to end. Is there any efficient way to do this?
Here is my code:
function del()
wave test
variable i
do    
if( test[i]==0)
deletepoints i, 1, test
else
i+=1
endif
while(i<numpnts(test))
end
Try


test = test == 0 ? NaN : test
WaveTransform zapNaNs test



In the first line each "0" of the wave test is set to not-a-number (NaN). The second line erases all NaN's from a wave.
If you wrap this in a function you might want to use

Multithread w = w == 0 ? NaN : w


to speed up things (w would be the wave reference to your wave of interest).
ChrLie wrote:
Try


test = test == 0 ? NaN : test
WaveTransform zapNaNs test



In the first line each "0" of the wave test is set to not-a-number (NaN). The second line erases all NaN's from a wave.
If you wrap this in a function you might want to use

Multithread w = w == 0 ? NaN : w


to speed up things (w would be the wave reference to your wave of interest).


Thanks a lot! Now the pro will be end within one second! It is very useful to operate the whole wave.
Sorry about the Pro, it seems that part of it are not shown on the Website, I do not know why