search through an array for patterns and put into cell arrays.
Show older comments
Looking to search through a large array of integers and find patterns of up to 1-10 ( can be 1 or 1 2 3 or 1 2 3 4 5 6 .. 10, etc) and place those into cell arrays. Resulting multiple cell arrays of different lengths. A is really long so I was hoping to avoid lengthy loops, in which I figured out a way using ismember and a very very long inefficient loop.
I do not know how many patterns of 1-10 exist. Is this possible? Thanks.
if true
A = [ 1 2 3 78 28 92 1 76 89 23 87 1 2 3 4 5 6 7 8 9 10 72 91 72]
result{1} = {1 2 3}
result{2} = {1}
result{3} = {1 2 3 4 5 6 7 8 9 10}
end
Accepted Answer
More Answers (0)
Categories
Find more on Shifting and Sorting Matrices 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!