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

Home » Public Forums » archive » Re: 2 arrays, average, missing data
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: 2 arrays, average, missing data [message #45411] Thu, 08 September 2005 10:31 Go to previous message
James Kuyper is currently offline  James Kuyper
Messages: 425
Registered: March 2000
Senior Member
Benjamin Luethi wrote:
> An short answer would be:
>
> C = (A+B)/((A NE 0)+(B NE 0))
>
> The divisor is 1+1=2 if both A and B are not 0.
> 0+1=1 if one of them is 0.
> 0+0=0 if both A and B are 0.
>
> If A and B are integer, divison by zero produces 0, which is the wanted
> result.
> If A or B are of type double or float, the third case produces NaN.
> Convert it
> to zero using:
>
> sel = where(finite(C,/NaN),count)
> if count gt 0 then C[sel] = 0

Simpler:
C = (A+B)/((A NE 0)+(B NE 0) > 1.0)
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Ordered index array
Next Topic: Re: Postscript colour sampler?

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

Current Time: Fri Oct 10 23:16:52 PDT 2025

Total time taken to generate the page: 1.04032 seconds