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


Groups > comp.soft-sys.math.mathematica > #11664 > unrolled thread

Count inside a matrix?

Started bySergio Sergio <zerge69@gmail.com>
First post2012-09-08 07:09 +0000
Last post2012-09-10 08:14 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  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

#11664 — Count inside a matrix?

FromSergio Sergio <zerge69@gmail.com>
Date2012-09-08 07:09 +0000
SubjectCount inside a matrix?
Message-ID<k2er00$k90$1@smc.vnet.net>
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

[toc] | [next] | [standalone]


#11690

FromDavid Reiss <dbreiss@gmail.com>
Date2012-09-10 08:14 +0000
Message-ID<k2k7hd$130$1@smc.vnet.net>
In reply to#11664
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

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web