Re: Re: Select Maximum Value
- To: mathgroup at smc.vnet.net
- Subject: [mg107977] Re: [mg107948] Re: Select Maximum Value
- From: DrMajorBob <btreat1 at austin.rr.com>
- Date: Thu, 4 Mar 2010 05:29:08 -0500 (EST)
- References: <201003020836.DAA03985@smc.vnet.net> <hmj274$eeo$1@smc.vnet.net>
- Reply-to: drmajorbob at yahoo.com
First of all, A={{1,2},{2,1},{3,4}},{{1,5},{2,1},{3,2}}... isn't an array. Or anything else. Secondly, if I set a = {{{1, 2}, {2, 1}, {3, 4}}, {{1, 5}, {2, 1}, {3, 2}}}; a // MatrixForm (eliminating "..." and adding the first and last missing brackets), MatrixForm shows that a is a 3-dimensional matrix, and the second column is a list of pairs. Specifically, the second column is a[[All, 2]] {{2, 1}, {2, 1}} Now, then... how do you want to choose a maximum in that column? Bobby On Wed, 03 Mar 2010 04:54:02 -0600, graser <graser at gmail.com> wrote: > On Mar 2, 8:01 am, Patrick Scheibe <psche... at trm.uni-leipzig.de> > wrote: >> Hi, >> >> it is simply >> >> A = {{2, 4, 1, 3, 2, 2}, {4, 7, 9, 1, 2, 4}}; >> >> Max /@ A >> >> and your code is not working at all. >> >> Cheers >> Patrick >> >> Am Mar 2, 2010 um 9:36 AM schrieb graser: >> >> >> >> > Hi >> >> > I want to pick up the maximum value of each list in the Array >> >> > A={{2, 4, 1, 3, 2, 2}, {4,7,9,1,2,4}} >> >> > I can do it in two steps.. >> >> > B=Table[Sort[A[[i]], #1>#2&], {i, 1, Length[A]}]; >> >> > C=Table[B[i], {i, 1, Length[B]}]; >> >> > But is there any way I can do it in just one step with Select function >> > or any thing else? >> >> > Thanks > > Thanks for all of your comments.. > > Here I have more question for you.. > > If Array has > > A={{1,2},{2,1},{3,4}},{{1,5},{2,1},{3,2}}.. > > Then If I want to pick up the list which has maximum value in second > column, So my result should be {{3,4},{1,5}}, can I still use the Max? > > It just give the maximum value in first column like {4,5} > > Or I have to use the multiple steps like > > B = Table[Sort[A[[i]], #1[[2]] > #2[[2]] &], {i, 1, Length[A]}]; > CD = Table[B[[i, 1]], {i, 1, Length[B]}]; > -- DrMajorBob at yahoo.com
- References:
- Select Maximum Value
- From: graser <graser@gmail.com>
- Select Maximum Value