Re: FIND the indexes of a value in a matrix [message #29980] |
Tue, 02 April 2002 13:34 |
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  |
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
|
|
|