How to ignore Nan value in an iteration

Hi guys,

I'm a beginner at Igor so don't be offended if my question is trivial :

My code is the following :

for(o=1;o<10;o=o+1)

graph_eq+=(tan(y*sqrt((2*pi*x/lambda)^2-betas[o]^2)-0.5*pi)-sqrt((betas[o]^2-(2*pi/lambda)^2)/((2*pi*x/lambda)^2-betas[o]^2))^2

endfor

I've got my x and y scale set, the issue is that for some values of x and betas the part unders the square root is negative, filling the matric graph_eq with Nan values.

Do you know a solution to ignore those values or remplace them with 0 ?

thanks,
You can change NaNs to 0 like this:

wave0 = numtype(wave0)==2 ? 0 : wave0


For details on ?:, execute:
DisplayHelpTopic "? :" // There is a space between the two characters in this string


You can also use the SelectNumber function instead of ?:
jack = SelectNumber(numtype(jack)==2, jack, 0)

Thank you it worked perfectly,

so what I did was to separate each iteration solution, then check for NaN value (& replace with 0 if necessary), and then add the solution to the previous iteration result.

Here's the code if somebody has the same issue :

SetScale/I x 1.4,1.6,"", graph_unit
SetScale/I y 1,3,"micron", graph_unit

for(o=1;o<10;o=o+1)

graph_unit=(tan(y*sqrt((2*pi*x/lambda)^2-betas[o]^2)-0.5*pi)-sqrt((betas[o]^2-(2*pi/lambda)^2)/((2*pi*x/lambda)^2-betas[o]^2)))^2
graph_unit= SelectNumber(numtype(graph_unit)==2, graph_unit, 0)
graph_eq+=graph_unit

endfor

Once again thanks guys.