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: How to select adjacent elements from an array?
Replies: 5   Last Post: May 26, 2015 5:59 PM

Advanced Search

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

Posts: 3
Registered: 9/23/13
How to select adjacent elements from an array?
Posted: Sep 23, 2013 4:43 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply


So if for example I have an array which looks like this:

array = [1 2 3 4 5 8 9 10 11 73 74]

I want a script which creates separate vectors with the adjacent elements, so:

data.first = [1 2 3 4 5]
data.second = [8 9 10 11]
data.third = [73 74]

The number of vectors is equal to the number of groups of adjacent elements.

Thank you.

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.