Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: consecutive numbers
Replies: 8   Last Post: Jul 6, 2013 11:01 PM

 Messages: [ Previous | Next ]
 fmri Posts: 50 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

Thanks

AS

Date Subject Author
7/5/13 fmri
7/6/13 fmri
7/6/13 dpb
7/6/13 dpb
7/6/13 fmri
7/6/13 dpb
7/6/13 james bejon
7/6/13 dpb
7/6/13 fmri