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

Home » Public Forums » archive » array handling
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 handling [message #74187 is a reply to message #52128] Mon, 03 January 2011 11:10 Go to previous messageGo to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
David Fanning wrote:
> bing999 writes:
>
>> Thanks for answering. But what I want is to divide the number of
>> elements of my array by 2 by keeping only elements with odd index for
>> instance. Is there an IDL routine which does it?
>
> IDL> array = indgen(10)
> IDL> print, array
> 0 1 2 3 4 5 6 7 8 9
> IDL> print, rebin(array, 5)
> 0 2 4 6 8

Or for the IDL 8-ers out there:

IDL> array = indgen(10)
IDL> print, array
0 1 2 3 4 5 6 7 8 9
IDL> print, array[0:-1:2]
0 2 4 6 8

and if you want the even indices (at least, even for those of us that start counting things at one :o),

IDL> print, array[1:-1:2]
1 3 5 7 9


cheers,

paulv


p.s. happy new year btw....
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: stl files
Next Topic: IDL output directed to STDERR-- can't seem to work around...

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

Current Time: Sat Oct 11 15:12:53 PDT 2025

Total time taken to generate the page: 1.67903 seconds