k permutation of an n-membered vector

Versión 1.0.2 (1,28 KB) por WinCento99
"perms" requires a lot of memory for vectors greater than 10 members.If you need limited permutations(k) of a vector, you can use "perms_k".
5 descargas
Actualizado 24 mar 2023

Ver licencia

For use with permutation of 6 and vector with 3 members:
perms_k([700 2 nan],6)
The output is as follows:
ans =
700 NaN 2
2 NaN 700
700 2 NaN
NaN 2 700
NaN 700 2
2 700 NaN
If you need indexes:
[~ , index] = perms_k([700 2 nan],6)
and output is:
index =
1 3 2
1 2 3
2 3 1
3 2 1
2 1 3
3 1 2
If the amount of permutation required is greater than the factorial of the number of members:
perms_k([700 2 nan],7)
or
[~ , index] = perms_k([700 2 nan],7)
You receive an error with the following content:
# Your chosen k is greater than the number of permutations. 7 is greater of 6.

Citar como

WinCento99 (2024). k permutation of an n-membered vector (https://www.mathworks.com/matlabcentral/fileexchange/126769-k-permutation-of-an-n-membered-vector), MATLAB Central File Exchange. Recuperado .

Compatibilidad con la versión de MATLAB
Se creó con R2018b
Compatible con cualquier versión
Compatibilidad con las plataformas
Windows macOS Linux
Etiquetas Añadir etiquetas

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.2

Its dimensions were improved.

1.0.1

I added a photo :)

1.0.0