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

Home » Public Forums » archive » subscripting arrays with dim > 1
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 #46250 is a reply to message #12707] Mon, 14 November 2005 01:53 Go to previous messageGo to previous message
wem is currently offline  wem
Messages: 6
Registered: October 2005
Junior Member
David Fanning wrote:
> Benjamin Hornberger writes:
>
>
>
>> 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?
>
>
> If by "elegant" you mean "correct", then the answer is no. :-)
>
> Cheers,
>
> David
>

And if you mean by "elegant", "more readable", then the answer is: yes ;-)

IDL> a = dist(300)
IDL> b = [30, 50]
IDL> x = b[0]
IDL> y = b[1]
IDL> print, a[x, y]

and using comments ;-)
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: allocating data to different array on each loop step
Next Topic: Re: Quickly Erasing lines on direct graphics images

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

Current Time: Sat Oct 11 07:55:38 PDT 2025

Total time taken to generate the page: 0.64190 seconds