k indexes from 1:n

Return matrix of all possible k indexes, it is C(n,k) variants
310 descargas
Actualizado 24 sep 2010

Ver licencia

http://simulations.narod.ru/
Using:
ind=all_combinations(n,k)
Number of all posible variants is nv=C(n,k)=n!/(k!*(n-k)!) (binomial coefficient)
ind is nv-by-k matrix. Example, 2 indexes from 1 2 3:
all_combinations(3,2)

ans =

1 2
1 3
2 3

Example 3 from 5:
all_combinations(5,3)

ans =

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

Citar como

Maxim Vedenyov (2024). k indexes from 1:n (https://www.mathworks.com/matlabcentral/fileexchange/28818-k-indexes-from-1-n), MATLAB Central File Exchange. Recuperado .

Compatibilidad con la versión de MATLAB
Se creó con R2009b
Compatible con cualquier versión
Compatibilidad con las plataformas
Windows macOS Linux
Categorías
Más información sobre Matrix Indexing en Help Center y MATLAB Answers.

Community Treasure Hunt

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

Start Hunting!
Versión Publicado Notas de la versión
1.0.0.0