Re: array subscripts [message #12847] |
Fri, 18 September 1998 00:00  |
Martin Schultz
Messages: 515 Registered: August 1997
|
Senior Member |
|
|
Kevin Ivory wrote:
>
>> Martin Schultz (mgs@io.harvard.edu) writes:
>>> PPS: And while we are at it... One of the most useful tips I got from
>>> David's book (so far) was the A[n:*] syntax to extract ranges from n to
>>> end. I am really grateful for this!
>
> David Fanning wrote:
>> I've been using this for so long I can't really remember
>> where I learned it, but I suspect it was from Ray Sterner's
>> unpublished (so far) IDL manuscript. He has dozens of
>> useful subscripting tips like this. :-)
>
> Perhaps you read the IDL manual? The book 'Building IDL Applications'
> has a chapter about 'Array Subscripts' with a section about 'Subscript
> Ranges'. ;-)
>
> By the way, the book is online:
> ftp://ftp.rsinc.com/pub/idl_5.1.1/info/docs/building.pdf
> See page 62.
>
> Cheers,
> Kevin
Thanks for pointing me to the right manual, Kevin. As I now understand,
the idea behind passing two or more "explicit" index arrays as
subscripts is to extract individual elements of an array, not a
rectangular domain.
Hence, A=FINDGEN(10,10)
B=A[ [1,2,3],[4,5,6] ]
returns A1,4 , A2,5 , and A3,6
whereas C=A[ [1,2,3], 4:6 ]
returns A1,4 A2,4 A3,4
A1,5 A2,5 A3,5
A1,6 A2,6 A3,6
(or the transposed form?)
I guess, this is one of those cases, where one gets into the habit of
certain things, and then you start wondering why things are not laid out
the way you need them. I must recognize, there are other people using
IDL for different purposes than me ;-)
Thanks again,
Martin.
--
------------------------------------------------------------ -------
Dr. Martin Schultz
Department for Earth&Planetary Sciences, Harvard University
109 Pierce Hall, 29 Oxford St., Cambridge, MA-02138, USA
phone: (617)-496-8318
fax : (617)-495-4551
e-mail: mgs@io.harvard.edu
Internet-homepage: http://www-as.harvard.edu/people/staff/mgs/
------------------------------------------------------------ -------
|
|
|