Why this little piece of Code don´t work?

Hello, i recently make a little function to find NaN´s in my waves, my first idea was the follow.

function refill(onda)
wave onda

variable i,n

do
    if (onda[i]==NaN)
        print "hola!"    //Debug
        onda[i]=1
        n=n+1           //NaN´s Counter
    endif
i=i+1
while (i<=numpnts(onda))
print n
end


but it can´t detect the NaN, what i´m doig wrong?
problem solved.

function refill(onda)
wave onda
 
variable i,n
 
do
    if (numtype(onda[i])==2)
        print "hola!"    //Debug
        onda[i]=1
        n=n+1           //NaN´s Counter
    endif
i=i+1
while (i<=numpnts(onda))
print n
end


thanks anyway.
greetings.
You could use WaveStats and return V_numNans.
That's not your point, I know, but FYI just in case!
HTH,
J

Replacing all NaNs with 1 can be done in an one-liner:

onda = numtype(onda)==2 ? 1 : onda
The sentence

onda = numtype(onda)==2 ? 1 : onda[/quote]

it´´s a good solution, but replace the NaNs with "1", but i want to delete the NaNs.
Thanks awirsing
purozongo wrote:
it´´s a good solution, but replace the NaNs with "1", but i want to delete the NaNs.
Thanks awirsing


I see. Try extract/o onda, onda, numtype(onda)!=2 instead.

A