RE: Count
- To: mathgroup at smc.vnet.net
- Subject: [mg47363] RE: [mg47330] Count
- From: David.Annetts at csiro.au
- Date: Tue, 6 Apr 2004 06:37:17 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Hi Paolo,
> if i have a time serie, how can i Count the elements of this
> time serie that are within a defined range
> Example:
>
> x={1,1.023,1.056,2.45,5.67,....}
>
> how can i Count the elements inside the range (1,3)?
It's a 2-step process. First off, select all elements in your series
within the range, then count them. For example,
In[9]:=
ser01 = Table[Random[Real, {-5, 5}], {10}]
cnt01 = Select[ser01 ,(1 < # < 3)&]
Length@cnt01
Out[9]=
{3.05377,-0.301533,-1.19397,-1.16077,4.70664,3.6502,-4.68973,-0.862422,4
.\
85626,1.97491}
Out[10]=
{1.97491}
Out[11]=
1
Just checking ...
In[15]:=
ser02 = Table[Random[Real, {3, 5}], {10}]
cnt02 = Select[ser02 ,(1 < # < 3)&]
Length@cnt01
Out[15]=
{4.29284,3.49001,4.44606,4.49608,4.68209,4.55032,3.68485,3.72823,4.74076
,4.\
82028}
Out[16]=
{}
Out[17]=
0
Regards,
Dave.
==========================================
Dr. David Annetts
EM Modelling Analyst
CSIRO DEM Tel: +612 9490 5416
North Ryde Fax: +612 9490 5467
Australia David.Annetts at csiro.au
===========================================