Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.



Re: Lengths of Continuous Line/Vector
Posted:
Jan 6, 2013 4:40 PM


max plank <avrialony@gmail.com> wrote in message <5f1a24c9122c4cf79ab4d816839abc2c@googlegroups.com>... > Let us define vector y = [0 0 0 1 1 1 1 0 0 0 1 1 0] > I would like to extract the length of the continuous line > (i.e: ones = [4,2], zeros = [3,3,1])           d = diff([0,find(diff(x)~=0),length(x)]); Zeros = d((x(1)>0)+1:2:end); Ones = d((x(1)<1)+1:2:end);
Note: You should avoid naming any variables 'ones' or 'zeros' (all lowercase) since those are names of matlab builtin functions.
Roger Stafford



