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


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

Re:Count inside a matrix?

From "ced.fuhrer" <ced.fuhrer@laposte.net>
Newsgroups comp.soft-sys.math.mathematica
Subject Re:Count inside a matrix?
Date 2012-09-09 09:13 +0000
Message-ID <k2hmj6$pu2$1@smc.vnet.net> (permalink)
Organization Time-Warner Telecom

Show all headers | View raw


Hi sergio!

Maybe an example could help to know what you want but: a matrix is a list of list so if
you specify the level in which you are seeking a number (or anything else...) you have
the result:

Count[{{a, a, b}, {b, a, a}, {a, b, a}}, b, 2] returns 3 (because 3 'b' appear )

Count[{{1, 2, 3}, {4, 5, 6}, {3, 3, 3}}, 3, 2] returns 4 (there are four 3 in level2 in
this matrix)

Count[{{1, 2, 3}, {4, 5, 6}, {3, 3, 3}}, 3] returns 0 (there are no 3 in level1 in this
matrix)

Count[{{1, 2, {3, 2, 1}}, {4, 5, 6}, {3, {3}, 3}}, 3, 2] returns 2 (there are two 3 in
level2 in this matrix)

Count[{{1, 2, {3, 2, 1}}, {4, 5, 6}, {3, {3}, 3}}, 3] returns 0 (there are no 3 in level1
in this matrix)

Count[{{1, 2, {3, 2, 1}}, {4, 5, 3}, {3, {3}, 3}}, 3, Infinity] returns 5 (there are five
3 in all levels in this matrix)

You can find other examples on web
http://reference.wolfram.com/mathematica/ref/Count.html

I hope helping you!
Bye

Ced
> Message du 08/09/12 09:10
> De : "Sergio Sergio"
> A : mathgroup@smc.vnet.net
> Copie =C3  :
> Objet : Count inside a matrix?
>
> 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 amatrix.
> Any tips?
>
> Thanks
>
>

Une messagerie gratuite, garantie =C3  vie et des services en plus, =C3=
=A7a vous tente ?
Je cr=C3=A9e ma bo=C3=AEte mail www.laposte.net

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


Thread

Re:Count inside a matrix? "ced.fuhrer" <ced.fuhrer@laposte.net> - 2012-09-09 09:13 +0000

csiph-web