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

Home » Public Forums » archive » Re: Array juggling help needed
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: Array juggling help needed [message #45685 is a reply to message #45684] Fri, 23 September 2005 06:40 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Haje Korth writes:

> I need to expand and an array non-uniformly based on its content. I am
> trying to to the following:
>
> input array: [1,5,4,1]
> output array should be: [1,0.2,0.2,0.2,0.2,0.2,0.25,0.25,0.25,0.25,1]
>
> Each elements of the input array is basically tuned into
> fltarr(inputarray[i])/inputarray[i] and the subarray concatenated. Is there
> a way to do this in one step, without using "for" loops and array
> concatenation? If not, I can work around this, but knowing for sure that
> this doesn't work would at least allow me to stop thinking about this
> problem. :-)
>
> To me this looks kind of like a "REPLICATE" for vectors function?

We've got to get more people reading that Histogram Tutorial.
Does anyone have a picture of a sexy young woman in a
"Histogram" T-shirt they want to share?

This is the "index chunking" problem discussed in the tutorial
and last week in this newsgroup:

IDL> n = [1, 5, 4, 1]
IDL> d = 1./n
IDL> print, d
1.00000 0.200000 0.250000 1.00000
IDL> h=histogram(total(n,/CUMULATIVE)-1,/BINSIZE,$
MIN=0,REVERSE_INDICES=ri)
IDL> I=ri[0:n_elements(h)-1]-ri[0]
IDL> print, d[I]
1.00 0.20 0.20 0.20 0.20 0.20 0.25 0.25 0.25 0.25

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Spin button widget??
Next Topic: Help needed: read procedure for SCAN-data (soil climate analysis network)

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

Current Time: Sat Oct 11 05:29:22 PDT 2025

Total time taken to generate the page: 1.03642 seconds