Return next combination

For example three-element combinations of 1:5

     1     2     3
     1     2     4
     1     2     5
     1     3     4
     1     3     5
     1     4     5
     2     3     4
     2     3     5
     2     4     5
     3     4     5

function should return

nextComb([1 3 5],5)
ans = [1 4 5] 

First input is the vector of which the next combination is searched. Second input is the scalar which indicates the length of the vector (1:n).

Solution Stats

38 Solutions

16 Solvers

Last Solution submitted on Aug 05, 2026

Last 200 Solutions

Problem Comments

Solution Comments

Show comments
Loading...

Problem Recent Solvers16

Suggested Problems

More from this Author92

Problem Tags

Community Treasure Hunt

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

Start Hunting!