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

Home » Public Forums » archive » what is the highest subscript in the array?!?
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: what is the highest subscript in the array?!? [message #70850 is a reply to message #70774] Fri, 07 May 2010 11:51 Go to previous messageGo to previous message
munka is currently offline  munka
Messages: 36
Registered: December 2009
Member
On May 7, 10:37 am, eddie <eha...@gmail.com> wrote:
>> PS:  Right before I posted this, I searched and  I figured that
>> array[[-1]] should return the highest array value... but it doesn't,
>> and I'm still stumped.
>
> Add a 'u' and it should.  A negative unsigned number "wraps" to
> produce a large number.
>
> IDL> array = indgen(10)
> IDL> print,array[[-1u]]
>        9
> This is similar to Carsten's huge number as an index.  You can use
> array[[-1ull]] if you are concerned that your array might have more
> than a gajillion elements.
>
> Unfortunately this trick only works for the last element, array[[-2u]]
> still returns the last element of the array, not the second to last.
>
> Cheers,
> eddie




IDL> flux=findgen(10)
IDL> print,flux
0.00000 1.00000 2.00000 3.00000 4.00000
5.00000
6.00000 7.00000 8.00000 9.00000
IDL> print,flux[[-1u]]
9.00000
IDL> print,flux[5:*]
5.00000 6.00000 7.00000 8.00000 9.00000





Yes! The -1u works! I think I remembered the "trick" that I was
originally thinking of. It doesn't do what I want it to do, but the
[[-1u]] works!

Thanks for the responses!
~Bill
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Plotting 3D array as a 'cloud'
Next Topic: Re: Begin-End matching in IDLDE?

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

Current Time: Fri Oct 10 05:19:15 PDT 2025

Total time taken to generate the page: 0.96022 seconds