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

Home » Public Forums » archive » Identifying the index of a repeated element in an 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: Identifying the index of a repeated element in an array [message #94521 is a reply to message #94520] Tue, 20 June 2017 16:56 Go to previous message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On 6/20/17 2:49 pm, thtran296@gmail.com wrote:
> Hello everybody,
>
> I have an array that looks like this:
> x = [1,2,3,4,5,0,1,2,0,0,0,0,1,2,3,0,0,0,1,2,3]
> I am interested in the location of the element "5" (index 4), "3" (index 14), and "3" (index 20).
> I am writing a program to output the above three indices.
> However, using min(where(x eq 3)) keeps giving me the index of the first 3, which I do not want.
> I need the index of the second 3, and the third 3.
>
> Is there any way to do this?
>
> Thank you so much!
>

I'm not sure of your question. Here is the answer to your question as
stated:

ind = where(x eq 3)
print, ind[1], ind[2]

Is this what you need?

Mike
--
Michael Galloy
www.michaelgalloy.com
Modern IDL: A Guide to IDL Programming (http://modernidl.idldev.com)
[Message index]
 
Read Message
Read Message
Previous Topic: Re: Principle Componets Analysis
Next Topic: IDL client for Redis database

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

Current Time: Sun Oct 12 16:33:29 PDT 2025

Total time taken to generate the page: 0.00228 seconds