Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #11664 > unrolled thread
| Started by | Sergio Sergio <zerge69@gmail.com> |
|---|---|
| First post | 2012-09-08 07:09 +0000 |
| Last post | 2012-09-10 08:14 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
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
| From | Sergio Sergio <zerge69@gmail.com> |
|---|---|
| Date | 2012-09-08 07:09 +0000 |
| Subject | Count 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]
| From | David Reiss <dbreiss@gmail.com> |
|---|---|
| Date | 2012-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