Re: Count inside a matrix?
- To: mathgroup at smc.vnet.net
- Subject: [mg128034] Re: Count inside a matrix?
- From: David Reiss <dbreiss at gmail.com>
- Date: Mon, 10 Sep 2012 04:04:40 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- Delivered-to: l-mathgroup@wolfram.com
- Delivered-to: mathgroup-newout@smc.vnet.net
- Delivered-to: mathgroup-newsend@smc.vnet.net
- References: <k2er00$k90$1@smc.vnet.net>
Use the 3rd argument of Count to specify the level down which to go in the pattern matching. E.g.: In[1]:= mat = { {1, a, b, \[Pi]}, {E, 2, 3, 1/3} } Out[1]= {{1, a, b, \[Pi]}, {E, 2, 3, 1/3}} In[2]:= Count[mat, _Integer, 2] Out[2]= 3 On Sep 8, 3:11 am, Sergio Sergio <zerg... at gmail.com> wrote: > Hi, does anybody know how to count elements within a matrix? > I know how that Count works for lists, but it does not seem to work for a matrix. > Any tips? > > Thanks