Re: Selecting Many Things Rather Than Selecting One Thing From Many
- To: mathgroup at smc.vnet.net
- Subject: [mg66210] Re: Selecting Many Things Rather Than Selecting One Thing From Many
- From: "Chris Chiasson" <chris.chiasson at gmail.com>
- Date: Thu, 4 May 2006 05:20:39 -0400 (EDT)
- References: <e39k7e$cno$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Select and Cases are very similar. I would recommend Cases for this. The code below gives results in a form similar to the one MathGroup showed you last time. In[1]:= dim=12; In[2]:= maxint=200; In[7]:= theMatrix=Table[Random[Integer,maxint],{dim},{dim}]; In[4]:= K=Extract[theMatrix, Table[{Random[Integer,{1,dim}],Random[Integer,{1,dim}]},{4}]] Out[4]= {46,54,171,17} In[5]:= Select[#1,#>maxint/2&]&/@Transpose[theMatrix] Out[5]= {{136,195,121,169,178,118,122},{195,190,106,149,171},{128,132, 135,168,195},{175,153,116,134,110, 122,193,174,173,166},{181,173,129,136},{192,135,150,141,136,191,130,101, 119},{105,161,152,102,195,188,174,102},{102,171,154,117, 155,114,132},{109,152,129,168,189,197,133,162},{122,123,145,128, 158,150},{107,190,106,121,169,123,177,194},{177,115,106,119,123,120,132}} In[6]:= Cases[#1,Alternatives@@K]&/@Transpose[theMatrix] Out[6]= {{},{46,54,171},{},{17},{},{46},{},{171},{},{46},{},{}}