Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #11690

Re: Count inside a matrix?

From David Reiss <dbreiss@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Count inside a matrix?
Date 2012-09-10 08:14 +0000
Message-ID <k2k7hd$130$1@smc.vnet.net> (permalink)
References <k2er00$k90$1@smc.vnet.net>
Organization Time-Warner Telecom

Show all headers | View raw


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...@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

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Count inside a matrix? Sergio Sergio <zerge69@gmail.com> - 2012-09-08 07:09 +0000
  Re: Count inside a matrix? David Reiss <dbreiss@gmail.com> - 2012-09-10 08:14 +0000

csiph-web