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

Home » Public Forums » archive » Re: FIND the indexes of a value in a matrix
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: FIND the indexes of a value in a matrix [message #29980] Tue, 02 April 2002 13:34
chi-kuei is currently offline  chi-kuei
Messages: 5
Registered: March 2002
Junior Member
Thanks a lot.

Chi-Kuei

"David Fanning" <david@dfanning.com> wrote in message
news:MPG.17138b63d0c4008598985b@news.frii.com...
> chi-kuei (twcollie@hotmail.com) writes:
>
>> I have a 1000 X 4 matrix. I want to know the position of one value,
say,
>> 2342, in that matrix. I am able to do this in MATLAB with "find". How
can I
>> do this in IDL? Is there a command in IDL does this? (I don't see any in
the
>> help file.) The only thing that I can do is creating for-loops.
>
> In IDL, you use the WHERE function:
>
> index = WHERE(matrix EQ 2342, count)
> IF count GT 0 THEN print, index, matrix[index]
>
> --
> David W. Fanning, Ph.D.
> Fanning Software Consulting
> Phone: 970-221-0438, E-mail: david@dfanning.com
> Coyote's Guide to IDL Programming: http://www.dfanning.com/
> Toll-Free IDL Book Orders: 1-888-461-0155
Re: FIND the indexes of a value in a matrix [message #29982 is a reply to message #29980] Tue, 02 April 2002 08:34 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
chi-kuei (twcollie@hotmail.com) writes:

> I have a 1000 X 4 matrix. I want to know the position of one value, say,
> 2342, in that matrix. I am able to do this in MATLAB with "find". How can I
> do this in IDL? Is there a command in IDL does this? (I don't see any in the
> help file.) The only thing that I can do is creating for-loops.

In IDL, you use the WHERE function:

index = WHERE(matrix EQ 2342, count)
IF count GT 0 THEN print, index, matrix[index]

--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Transparent texture mapped polygons
Next Topic: Re: Findfile finds no files

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

Current Time: Wed Oct 08 20:00:00 PDT 2025

Total time taken to generate the page: 0.00569 seconds