consecutive combination of numbers from a list

1 Ansicht (letzte 30 Tage)
Jamie Onasis
Jamie Onasis am 15 Aug. 2019
Bearbeitet: Bruno Luong am 15 Aug. 2019
any quick methods to obtain a count of complete consecutive n numbers from a array list 1:m e.g. a list 1:21 and n=3 so
it would be 1:3,4:6,7:9,10:12,13:15,16:18,19:21,2:4,5:6,...17:19,3:5,...18:20= 19 combinations.

Akzeptierte Antwort

Bruno Luong
Bruno Luong am 15 Aug. 2019
Bearbeitet: Bruno Luong am 15 Aug. 2019
>> (1:19)'+(0:2) % (1:m-n+1)'+(0:n-1)
ans =
1 2 3
2 3 4
3 4 5
4 5 6
5 6 7
6 7 8
7 8 9
8 9 10
9 10 11
10 11 12
11 12 13
12 13 14
13 14 15
14 15 16
15 16 17
16 17 18
17 18 19
18 19 20
19 20 21

Weitere Antworten (0)

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by