Re: Need Help to find max position location
- To: mathgroup at smc.vnet.net
- Subject: [mg86600] Re: Need Help to find max position location
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Fri, 14 Mar 2008 04:18:56 -0500 (EST)
On 3/13/08 at 8:51 PM, tpnycity at yahoo.com (haitomi) wrote: >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 10 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}} The function you want is Ordering. Using this example with the matrix assigned to the variable data, either In[4]:= Ordering[#, -1] & /@ data // Flatten Out[4]= {1,2,1} Or In[5]:= (Ordering /@ data)[[All, -1]] Out[5]= {1,2,1} does the trick -- To reply via email subtract one hundred and four