Re: Need help to find position of max location

*To*: mathgroup at smc.vnet.net*Subject*: [mg86583] Re: Need help to find position of max location*From*: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>*Date*: Thu, 13 Mar 2008 20:56:23 -0500 (EST)*Organization*: Uni Leipzig*References*: <fras8b$1cc$1@smc.vnet.net>*Reply-to*: kuska at informatik.uni-leipzig.de

Hi, MaxRow[mtx_?MatrixQ] := MaxRow /@ mtx MaxRow[lst_List] := Position[lst, Max[lst]] /. {i_Integer} :> i and MaxRow[{{82, 71, 62, 47}, {52, 96, 31, 36}, {94, 52, 86, 12}}] will return {{1}, {2}, {1}} I would not suggest to have a result like {1,2,1} because you can have more than a single occurrence of the maximum and MaxRow[{{82, 71, 82, 47}, {52, 96, 31, 36}, {94, 52, 86, 12}}] will return {{1, 3}, {2}, {1}} as it should. Regards Jens haitomi wrote: > Hi All, > > I would like to find position of this problem > > Write a function that returns a list that gives the column location of the largest integer in each row of a matrix (a list of lists) of random integers between 30 and 99. > > Example, for the following 3 X 4 matrix the result is > > {1,2,1} > > { > {82, 71, 62, 47}, > {52, 96, 31, 36}, > {94, 52, 86, 12}, > > } > > t=Table[RandomInteger[{30,99}],{i,1,3},{j,1,4}] > > max=Map[Max,t] > > and I stuck at Position of each Row, if someone can help me. > > Thanks >