k indexes from 1:n
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
Compatibilidad con las plataformas
Windows macOS LinuxCategorías
Etiquetas
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Descubra Live Editor
Cree scripts con código, salida y texto formateado en un documento ejecutable.
Versión | Publicado | Notas de la versión | |
---|---|---|---|
1.0.0.0 |