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

Home » Public Forums » archive » Re: about MIN of 2D array
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: about MIN of 2D array [message #32713] Mon, 28 October 2002 16:20
Julia is currently offline  Julia
Messages: 11
Registered: July 2002
Junior Member
Thank you so much. It works!!!

Besides, can it be done in IDL5.4?

Regards,

Julia

"Mike Chinander" <mchinand@midway.uchicago.edu> wrote in message
news:Bqiv9.43$P4.10093@news.uchicago.edu...
> In article <apk9t5$6pr$1@dipsy.missouri.edu>,
> Julia <julia65201@yahoo.com> wrote:
>> hi, there,
>>
>> I have a queation about MIN.
>>
>> If I have a 2-dimension array, I want to get the value and position of
>> minimum on each row. Is there a function in IDL can do this?
>>
>> Since for loop is not time efficient, so it is not suggested here.
>>
>> Any suggestion will be apprecaited.
>>
>> Regards,
>>
>> Julia
>>
>>
>
> In IDL 5.5 you can do:
>
> min_row=min(array,index,dimension=1)
>
> min_row will contain the min of each row and index will give the index of
> the min. The index value will be from 0 to number of elements in the
> array. If you want the column number that contains the minimum value for
> each row you can use:
>
> row_index= index mod n_cols
>
> where n_cols is the number of columns in your array.
>
> Hope that helps,
>
> --Mike
>
>
> --
> Michael Chinander
> m-chinander@uchicago.edu
> Department of Radiology
> University of Chicago
Re: about MIN of 2D array [message #32714 is a reply to message #32713] Mon, 28 October 2002 13:58 Go to previous message
mchinand is currently offline  mchinand
Messages: 66
Registered: September 1996
Member
In article <apk9t5$6pr$1@dipsy.missouri.edu>,
Julia <julia65201@yahoo.com> wrote:
> hi, there,
>
> I have a queation about MIN.
>
> If I have a 2-dimension array, I want to get the value and position of
> minimum on each row. Is there a function in IDL can do this?
>
> Since for loop is not time efficient, so it is not suggested here.
>
> Any suggestion will be apprecaited.
>
> Regards,
>
> Julia
>
>

In IDL 5.5 you can do:

min_row=min(array,index,dimension=1)

min_row will contain the min of each row and index will give the index of
the min. The index value will be from 0 to number of elements in the
array. If you want the column number that contains the minimum value for
each row you can use:

row_index= index mod n_cols

where n_cols is the number of columns in your array.

Hope that helps,

--Mike


--
Michael Chinander
m-chinander@uchicago.edu
Department of Radiology
University of Chicago
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: about MIN of 2D array
Next Topic: Re: Object Graphics Printing

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

Current Time: Wed Oct 08 13:49:26 PDT 2025

Total time taken to generate the page: 0.00504 seconds