Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: consecutive numbers
Date: Sat, 6 Jul 2013 18:05:10 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 28
Message-ID: <kr9m8m$c98$1@newscl01ah.mathworks.com>
References: <kr6gus$b8d$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-00-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1373133910 12584 172.30.248.45 (6 Jul 2013 18:05:10 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 6 Jul 2013 18:05:10 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 4279012
Xref: news.mathworks.com comp.soft-sys.matlab:798913

"fmri" wrote in message <kr6gus$b8d$1@newscl01ah.mathworks.com>...
> Hi all,
> 
> I posted this before but I need something else with it :-)
> 
> I have a vector that has consecutive number every x or b (so they are repeated randomly ) and then another consecutive numbers that are not related to the previous one stored in another different length.
> 
> example :
> x= [ 1 2 3 7 8 9 10 13 14 20 21 22 23 24 ]
> What I want is to represent every ( length of consecutive number by a single number So I want:
> y= [ 1 1 1 2 2 2 2 3 3 4 4 4 4 4] 
> 
> I was able to do this in excel by this command (assuming our consecutive column in C and started at C2 and the new column is J )
> =IF(C3=C2+1,J2,J2+1)
> 
> I tried to do this in matlab but it did not work ( I tried to do something similar to the excel code )
> for i=1:4741 , if ss((i+1),1)==ss((i),1)+1, b,b((i),1)+1 end end
> 
> So i = 1:4741 is the length of the consecutive numbers
> 
> Any suggestions please 
> 
> Thanks
> 
> AS


Updates