How can I obtain the permutation of 3 binary variables?
18 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Matteo Masto
el 22 de Sept. de 2021
Comentada: Rik
el 22 de Sept. de 2021
Hi everyone!
Can anybody tell me how to obtain the classical permutation matrix of binary variables?
for example given n=3 boolean variables A B C:
ABC
000
001
010
011
100
101
110
111
I hope there would be a command for this.
thank you!!
0 comentarios
Respuesta aceptada
Rik
el 22 de Sept. de 2021
The easiest way to do this is with bin2dec. You can loop from 0 to 2^n-1 to get all combinations. To convert the character array back to a numeric vector you can simply use =='1'.
4 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Operators and Elementary Operations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!