Find all 0 of the wave

Hi!!

I am new of Igor, and I search to make a table with all cordinates where my wave=0.

I have a wavetime, and on the wavetime, I have cycles of time, but cycles are not the same length, so I want to find all the row when the wavetime=0 and put it on the table.

Thanks for your help.
function zero_finder(yourwave)
wave yourwave

variable i,j=0
make/o/n=(numpnts(yourwave)) outputwave

for (i=0;i<=numpnts(yourwave);i+=1)
if (yourwave[i] == 0)
outputwave[j] = i
j = j+1
endif
endfor

edit
appendtotable outputwave

end


That will give you an outputwave with the point positions of the zeros in order. Up to you what you do with it from there.. You can of course change the names or use references etc..

No problem. One thing I forgot, you might want to redimension your wave at the end before appending it to the table, so that it has j+1 points. That will preserve all the real point values and chop all the zeros at the end off. The wave was originally created to match yourwave in length because you pretty much have to declare a length (or get tricky) and that way it will still work if by chance your wave is all zeros, but thats why there are all those extra zeros..
It will eventually be of value to you to take full advantage of Igor's built-in wave indexing capability, to avoid unnecessary loops. Here is an example of code that does what you want without explicit index loops:
function zeros(inwave)
    wave inwave
   
    string sname = NameOfWave(inwave)+"_0"
    duplicate/O inwave, $sname
    wave zwave=$sname
    zwave =  (inwave[p]==0) ? p : NaN
    WaveTransform zapNaNs, zwave // optional   
end

This also offers an auto-naming feature to the wave with zero locations. The last line in the function removes the NaNs from the wave, and reduces its size. If you delete it, or comment it out, the table containing it will have blanks for non-zero points, and will align in the table with the original wave.
Note that the prior solution creates a new table every time it is called. This might cause some inconvenience, so I have omitted the 'Edit' command. Also, the prior solution might have a 0 at the 0'th point of the input wave, and then a trail of 0's at the end, possibly leading to further problems.
A point I neglected to mention is the pitfall in testing for the exact equality of a point with 0. Sometimes rather than using
zwave =  (inwave[p]==0) ? p : NaN

it might be safer to use
zwave =  ( abs(inwave[p])< eps ) ? p : NaN

to avoid floating point accuracy problems, where eps is a tolerance variable you define.