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

Home » Public Forums » archive » Re: Oooh...! It's harder than I thought!! To get average of each line using only meaningful 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: Oooh...! It's harder than I thought!! To get average of each line using only meaningful data [message #54947] Tue, 24 July 2007 08:52 Go to previous message
Conor is currently offline  Conor
Messages: 138
Registered: February 2007
Senior Member
On Jul 24, 11:40 am, "edward.s.mei...@aero.org" <mei...@aero.org>
wrote:
> On Jul 24, 8:47 am, Conor <cmanc...@gmail.com> wrote:
>
>
>
>> totals = total(data_arr,1)/total(data_arr<1,1)
>
>> total(data_arr,1) returns a row vector where each element is the total
>> of a single line of data. total(data_arr<1,1) does essentially the
>> same thing, but first it imposes a ceiling on the array, so that no
>> value is greater than 1. Then, when you total across a line, what you
>> get is the total number of non-zero elements.
>
> Very clever, Conor! It just needs one small change: You have assumed
> that the total number of non-zero elements is, well, non-zero. If
> there are no non-zero elements, it will choke, so just do,
>
> totals = total(data_arr,1)/(total(data_arr<1,1) > 1)
>
> I use the */(* > 1) trick quite frequently.
>
> Ed

Good call. I always forget to check for things like that :) On a
related note, I've also assumed that the data is integer data. This
would fail for floats (or, at least for any values between 0 and 1)
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: IDL crashing on call of TV - solved
Next Topic: Re: recommendations for curve fitting

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

Current Time: Fri Oct 10 02:10:38 PDT 2025

Total time taken to generate the page: 0.96259 seconds