comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: How to locate a "NaN"?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: How to locate a "NaN"? [message #56265 is a reply to message #56257] Tue, 09 October 2007 01:26 Go to previous messageGo to previous message
lasse is currently offline  lasse
Messages: 48
Registered: February 2007
Member
On 9 Oct, 07:12, mystea <idllear...@gmail.com> wrote:
> Hello All,
>
> I have a array of length 100. A significant portion of them is
> recorded as NaN. Now I want to figure out what is the largest index of
> the element that contains a valid number, then assign its value to
> these NaN entries.
>
> I thought it would be easy and tried:
>
> IDL> k=max(where(myarray[*] ne !VALUES.D_NAN))
>
> but it does not work! k equals to 99 in this case. what's really
> strange is the following:
>
> IDL> help, myarray[50]
> <Expression> DOUBLE = NaN
>
> IDL>print, (myarray[50] eq !VALUES.D_NAN)
> 0
> (so I think this means myarray[50] is double, is NAN, yet is not !
> VALUES.D_NAN)
>
> In short, the problem is, how to locate array elements whose values
> are NaN?

It might be worth noting here that *nothing* is equal to NaNs. Even

!values.f_nan eq !values.f_nan and
!values.d_nan eq !values.d_nan

returns false (at least on my machine, there might be differences
between different platforms, although there shouldn't). This result is
obvious, really, because if it is a NaN (=Not A Number), how can it be
equal to anything?

And fanxing is right, only the finite() function will tell you where
NaNs are.

Cheers
Lasse
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Get unlimited visitors to your website
Next Topic: y axis tickmarks and box_plot

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 09:30:30 PDT 2025

Total time taken to generate the page: 0.64083 seconds