The Math Forum

Search All of the Math Forum:

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

Math Forum » Discussions » Software » comp.soft-sys.matlab

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

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]

Posts: 50
Registered: 5/1/13
consecutive numbers
Posted: Jul 5, 2013 9:16 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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 )

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



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.