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

Home » Public Forums » archive » subscripting arrays
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: subscripting arrays [message #46417 is a reply to message #46258] Tue, 22 November 2005 01:36 Go to previous message
Chris Lee is currently offline  Chris Lee
Messages: 101
Registered: August 2003
Senior Member
Benjamin Hornberger wrote:
> Hi all,
>
> this is probably simple, but I can't figure it out right now:
>
> I want to extract an element from a 2d array, and I have the 2d
> subscripts of that element available as a 2-element vector.
>
> IDL> a = dist(300)
> IDL> b = [30, 50]
> IDL> print, a[b]
> 30.0000 50.0000
>
> Not what I want. What I want is
>
> IDL> print, a[b[0], b[1]]
> 58.3095
>
> Is there a more elegant way than splitting b up?
>
> Thanks,
> Benjamin

You can get the correct answer using the one-dimensional index.

a=dist(300)
b=[30,50]
scale=[1,300]
print, a[total(b*scale)]

but it's not very elegant.

Chris.
[Message index]
 
Read Message
Read Message
Previous Topic: Re: Best platform for IDL 6.2?
Next Topic: Re: SMOOTH function for 3D

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

Current Time: Fri Oct 10 09:03:06 PDT 2025

Total time taken to generate the page: 0.00660 seconds