Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


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

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 ]
fmri

Posts: 42
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 )
=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



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

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.