combination cases using a value more than once

A = [1 2 3 4 5]
I want to create a matrix of all possible combinations for no. of columns, n=3
[1 1 1; 1 1 2; 1 1 3; 1 2 1; ...; 5 5 5]
I want the value of A and n to be variable. I tried to use nchoosek but I can not get it to do what I want
Is there a function that does this for me?

Respuestas (1)

Geoff Hayes
Geoff Hayes el 24 de En. de 2015
Jack - see Matt Fig's File Exchange submission at combinator. The call
combinator(5,3,'p','r')
should do what you want.

Categorías

Más información sobre Discrete Math en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 24 de En. de 2015

Respondida:

el 24 de En. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by