Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Selecting Many Things Rather Than Selecting One Thi ng From Many

  • To: mathgroup at smc.vnet.net
  • Subject: [mg66205] Re: [mg66180] Selecting Many Things Rather Than Selecting One Thi ng From Many
  • From: Gregory Lypny <gregory.lypny at videotron.ca>
  • Date: Thu, 4 May 2006 05:20:11 -0400 (EDT)
  • References: <7F445947D47B504E96A35290F059ECADBA844D@S4DE8PSAAMA.t-systems.com>
  • Sender: owner-wri-mathgroup at wolfram.com

Thank you, Hartmut.

The OR operator is intuitive and certainly does the trick for a short  
list of things to identify.

	Gregory

On Wed, May 3, 2006, at 5:22 AM, Hartmut.Wolf at t-systems.com wrote:

>
>> -----Original Message-----
>> From: Gregory Lypny [mailto:gregory.lypny at videotron.ca]
To: mathgroup at smc.vnet.net
>> Sent: Wednesday, May 03, 2006 8:45 AM
>> To: mathgroup at smc.vnet.net
>> Subject: [mg66205] [mg66180] Selecting Many Things Rather Than
>> Selecting One Thing From Many
>>
>> Hello everyone,
>>
>> I've discovered another use or need for the Select function, which I
>> suspect requires mapping of some sort.
>>
>> In my previous posts, members of this MathGroup kindly showed me how
>> to apply Select to many columns of a matrix at once.  For example,
>>
>> (Select[#1, #1 > K & ] & ) /@ Transpose[theMatrix]
>>
>> will pull out all values greater than K, where K is a number such as
>> 100.
>>
>> But suppose now that K is a list of numbers, such as K={34, 876,
>> 199}, and I simply want to extract or identify all of the
>> rows in the
>> first column of theMatrix equal to any one of those numbers.  How
>> would I do that?  I started with
>>
>> Select[theMatrix, #[[1]]==any element of list K]
>>
>> and I imagine something similar could be applied to the Position
>> function.
>>
>> Any hint would be much appreciated.
>>
>> 	Gregory
>>
>
> Gregory,
>
> this is simple and perhaps good enough to identify the rows:
>
> In[6]:= M = Table[Random[Integer, {0, 9999}], {100000}, {5}]; //  
> Timing
> Out[6]= {0.282 Second, Null}
>
> In[7]:= Position[M[[All, 1]], 34 | 199 | 876] // Timing
> Out[7]=
> {0.046 Second, {{4721}, {11778}, {17337}, {20008}, {20322},  
> {20934}, {26451}, \
> {27608}, {27754}, {32699}, {34359}, {34653}, {39046}, {42495},  
> {42506}, \
> {46940}, {49889}, {52322}, {54645}, {56331}, {57269}, {58562},  
> {59262}, \
> {62137}, {62139}, {65675}, {68442}, {69835}, {71695}, {73574},  
> {74835}, \
> {75793}, {88403}, {89449}, {93625}, {93871}, {97970}}}
>
> In[8]:= M[[59262]]
> Out[8]= {199, 7540, 3117, 7756, 9193}
>
> --
> Hartmut


  • Prev by Date: Re: Beginner--Help on using FindRoot to solve the system of equations
  • Next by Date: Re: Selecting Many Things Rather Than Selecting One Thing From Many
  • Previous by thread: Re: Selecting Many Things Rather Than Selecting One Thing FromMany
  • Next by thread: Determining Linear dependent vectors