Re: where function not finding value [message #90572 is a reply to message #90571] |
Wed, 11 March 2015 02:16   |
Jahvasc
Messages: 9 Registered: March 2014
|
Junior Member |
|
|
Thank you all for your replies.
As I told you, I am aware of the problems caused by floating point precision and I also know that is not related to IDL itself. However, what has astonished me was the fact that different functions or ways to address the problem in IDL produced such discrepant results.
Because of your help, I realised that the problem was in the way I was defining the intervals. In fact, they were too large. Then, I re-wrote the program introducing an eps=1.e-3 value. The loop turned-out to be:
mmod=[findgen(10)*0.01+0.01,findgen(3)*0.1+0.2]
eps=1.d-3
for j=0,12 do begin
a=where(massa ge mmod[j]-eps and massa le mmod[j]+eps,count)
print,mmod(j),count
endfor
Now I get the right counts.
Thank you again!
Cheers,
Jaqueline
|
|
|