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 #45415 is a reply to message #45414] Thu, 08 September 2005 07:53 Go to previous messageGo to previous message
R.G. Stockwell is currently offline  R.G. Stockwell
Messages: 363
Registered: July 1999
Senior Member
"KJM" <kimberlite@gmail.com> wrote in message
news:1126189124.079832.197820@f14g2000cwb.googlegroups.com.. .
> HI All,
...
> If A = 0, C = B
> If B = 0, C = A
> If A and B EQ 0, C = 0
> If A and B NE 0, C = (A+B)/2
> Any help appreciated!
> Thanks.

Hi,
something along the lines of

gooddata = a*b
c = dblarr(n_elements(a))
zeros = where(gooddata eq 0,count,complement = nonzeros)
if count gt 0 then begin
c[nonzeros] = (a[nonzeros]+b[nonzeros])/2
c[zeros] = a[zeros] > b[zeros]
endif


NOTE: this assumes the values are greater than zero.
If they are not, then using zeros as the "bad value" may cause some
problems.

Cheers,
bob
[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: Sun Oct 12 05:05:29 PDT 2025

Total time taken to generate the page: 2.80361 seconds