MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Count Function


Gregory Lypny wrote:
> The syntax will be the death of me.
> 
> Count[X[[All,14]], -9.] will tally how many elements in column 14 of
> matrix X are equal to -9, but I can't for the life of me figure out
> how to get how many are greater than -9.  Any hint would be most
> appreciated.

Use a guard function that matches only suitable elements:

  In[1] := Count[{1,2,3,4,5,6,7,8,9}, n_?(#>5&)]

  Out[1] = 4

-- 
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/products/ocaml_for_scientists/chapter1.html


  • Prev by Date: Re: HoldFirst question
  • Next by Date: Permutations
  • Previous by thread: Re: Re: Count Function
  • Next by thread: Re: Count Function