[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: find frequencies
From: 
Laurent Jacques 
Subject: 
Re: find frequencies 
Date: 
Mon, 9 Dec 2002 13:17:47 +0100 
Useragent: 
KMail/1.4.3 
Is this right ?
octave> a=[1,2,3,0,5,6,0,0,9,0,0,0,13,14,0]
a =
1 2 3 0 5 6 0 0 9 0 0 0 13 14 0
octave> pos=find(diff([~a 0])==1)
pos =
4 8 12 15
octave> csum=cumsum(~a)
csum =
0 0 0 1 1 1 2 3 3 4 5 6 6 6 7
octave> diff([0 csum(pos)])
ans =
1 2 3 1
Laurent
On Monday 09 December 2002 12:41, Paolo Ariano wrote:
 hi *,
 Studing Kangaroo model, i'm searching for a startpoint to solve this
 (probably stupid) problem:

 to simplify i define a vector (a) as follow:

 octave> a=[1,2,3,0,5,6,0,0,9,0,0,0,13,14,0]

 i'd like to have a new vector (b) with the frequencies of a subsequent
 particular value, in this case "0" so the result is:

 a=[1,2,3,0,5,6,0,0,9,0,0,0,13,14,0]
 ^ ^ ^ ^ ^ ^ ^
 1 2 3 1

 b=[1,2,3,1]

 do you have any idea ?

 thanks
 paolo

Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html

 find frequencies, Paolo Ariano, 2002/12/09
 Re: find frequencies,
Laurent Jacques <=