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


fmri
Posts:
49
Registered:
5/1/13


consecutive numbers
Posted:
Jul 5, 2013 9:16 AM


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



