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
what is the highest subscript in the array?!? [message #70774] Thu, 06 May 2010 19:12 Go to previous message
munka is currently offline  munka
Messages: 36
Registered: December 2009
Member
Hello team,

I find myself wanting to use the highest subscript in an array and
coding "flux[n_elements(flux)-1]"... I seem to remember seeing a
shortcut on here, and I can't remember what it is.

It's irrelevant, but here is where I most recently used this. This
finds the local maximum in an array.
index=where(flux eq max(flux) and flux ne flux[0] and flux ne
flux[n_elements(flux)-1],ct)

Thanks in advance,

~Bill


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.

IDL> array=indgen(10)
IDL> print,array[0]
0
IDL> print,array[9]
9
IDL> print,array[10]
% Attempt to subscript ARRAY with <INT ( 10)> is out of
range.
% Execution halted at: $MAIN$
IDL> print,array[[10]]
9
IDL> print,array[[-1]]
0
IDL> print,array[[-2]]
0
IDL>
[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: Wed Oct 08 15:18:38 PDT 2025

Total time taken to generate the page: 0.00263 seconds