MATLAB: List(Vecor) Generation

list generation

Can I generate list [1 2 3 2 3 4 3 4 5 4 5 6 ….] without for loop?
Thanks!

Best Answer

  • m=3; % pairs
    n=4; % n combinations
    reshape((0:n-1)+(1:m)',1,[])