Borrar filtros
Borrar filtros

set of vectors from some elements?

2 visualizaciones (últimos 30 días)
Maha Mosalam
Maha Mosalam el 15 de Abr. de 2023
Comentada: Maha Mosalam el 15 de Abr. de 2023
How I can obtain a set of vectors from some elements by changing its positions
for example, If I had v=[ 1 2 3 4] elemnts , thus I want to generate all cobninations of vectors , like
result= [ 1 2 3 4
2 1 3 4
4 2 3 1
1 4 3 2
....]

Respuestas (1)

Rik
Rik el 15 de Abr. de 2023
Do you need all permutations in one array? Then you can use the perms function. Note that the array size quickly grows with the number of elements in your vector.
If you don't need all combinations in one array, you may consider procedurally generating the swaps.

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by