How to ignore Nan value in an iteration
neogin
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,
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
February 25, 2010 at 10:37 am - Permalink
For details on ?:, execute:
You can also use the SelectNumber function instead of ?:
February 25, 2010 at 07:00 pm - Permalink
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.
February 26, 2010 at 01:11 am - Permalink