How to group sets of data based on linearly increasing sequence into individual column vectors, and to also return indexing range of where the data set started and ended for each subvector produced from the original column vector
Show older comments
Hello,
Lets say I have a column vector that contains data such as,
A = [5;6;7;8;9;10;52;53;54;55;84;85;86;87;88;89;90;91]
I was wondering what would be the simplest and most easy-to-understand method of returning column vectors that groups the data into sets based on their linearly increasing sequence such as,
%Preferred output would be three vectors, each containing a set of data from A:
A1 = [5;6;7;8;9;10],
A2 = [52;53;54;55],
A3 = [84;85;86;87;88;89;90;91].
And also outputs the index range where each data set/grouping started and ended in the original column vector, A, so something like (or if you have a better idea for displaying the output, feel free to share):
a = [1 6] %Since A1 began at A(1) and ended at A(6).
b = [7 10]
c = [11 18]
Does that make sense? I have MATLAB R2015a btw. Please excuse my limited MATLAB programming vocabulary as I am still learning.
Thanks in advance, and any advice would be appreciated.
Accepted Answer
More Answers (0)
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!