MathGroup Archive 2005

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

Search the Archive

Re: Count using pattern on two different matrices

  • To: mathgroup at smc.vnet.net
  • Subject: [mg57093] Re: [mg57079] Count using pattern on two different matrices
  • From: Chris Chiasson <chris.chiasson at gmail.com>
  • Date: Sun, 15 May 2005 03:03:47 -0400 (EDT)
  • References: <200505140858.EAA09500@smc.vnet.net>
  • Reply-to: Chris Chiasson <chris.chiasson at gmail.com>
  • Sender: owner-wri-mathgroup at wolfram.com

Lee,
You could try:
MapThread[If[#1[[2]]==True&&#2[[3]]==False,++i]&,{L1,L2}];

or maybe:
Scan[If[#,++i]&,MapThread[#1[[2]]==True&&#2[[3]]==False&,{L1,L2}]]


On 5/14/05, Lee Newman <leenewm at umich.edu> wrote:
> I have two matrices with an equal number of rows, but not necessarily
> columns, for example:
> 
> L1= {{True,False},{False, True},{False, False}, etc.....} ;
> L2= {{True,False,False},{True, True,True},{False, True,False}, etc.....} ;
> 
> I would like to compute a count of the number of rows in which one of
> the columns of L1 meets some criterion, and one of the columns of L2
> meets some criterion, i.e.  If L1[[row,2 ]]==False  and
> L2[[row,3]]==True  then this row contributes 1 to the count.
> 
> I suspect that there is an elegant way to do this, perhaps using Count[]
> and MapThread, but I can't figure it out other than resorting to a
> rather clumsy For or Do loop that would check line by line and maintain
> a counter.
> 
> Any help would be appreciated,
> Lee
> 
> 


-- 
Chris Chiasson
http://chrischiasson.com/
1 (810) 265-3161


  • Prev by Date: Re: Count using pattern on two different matrices
  • Next by Date: Re: Count using pattern on two different matrices
  • Previous by thread: Re: Count using pattern on two different matrices
  • Next by thread: Re: Count using pattern on two different matrices