comp.lang.idl-pvwave archive - RDF feed
type: channel
description: Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
items: Identifying the index of a repeated element in an array
items: Re: Identifying the index of a repeated element in an array

Identifying the index of a repeated element in an array
type: item
description: 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!
creator: thtran296
date: 2017-06-20T20:49:37-00:00

Re: Identifying the index of a repeated element in an array
type: item
description: 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)
creator: Michael Galloy
date: 2017-06-20T23:56:09-00:00