generate a matrix from given Bit combinations
Mostrar comentarios más antiguos
Iam having a list of all possible bit combinations
For Example : if it is 3bit there will be (2)^3 - 1 combinations which is 7 combinations given below
A = [1,0,1 ; 1,1,1 ; 1,1,0 ; 0,1,1 ; 0,1,0 ; 0,0,1 ; 0,1,1]
Here aij used in below paragraph means ith row and jth column in B matrix
Now i want to generate a matrix based on visiting bit pattern for example for the above given bit combinations we need to generate a 7*7 matrix (because of 7 combinations), where first we will visit bit combination 1,0,1 and then 1,1,1 so cell a12 is 1 and other cells in 1st row is zero. In a12 - 1 represents 1,0,1 and 2 represents 1,1,1 ; which means if we visit 1,1,1 immediately after visiting 1,0,1 then a12 is 1 and remaining cells in that same row is zero because we dont want jumping from 1st combination(1,0,1) to (0,1,1) which is a14 is 0. so i need a matrix like given below
B = [ 0 1 0 0 0 0 0 ; 0 0 1 0 0 0 0 ; 0 0 0 1 0 0 0 ; 0 0 0 0 1 0 0 ; 0 0 0 0 0 1 0 ; 0 0 0 0 0 0 1 ; 0 0 0 0 0 0 0]
Here a12 is 1(since we first visit 1,0,1 and then 1,1,1) , a23 is 1 (we first visit 1,1,1 and then 1,1,0) similarly a34 is 1 , a45 is 1 , a56 is 1 , a67 is 1 and a78 is 1 (not possible so last row(7th) all zero row).
NOTE : i need a generalized code where i can generate a matrix based on bit combinations for example 4 bit means (2)^4 - 1 which is 15 combinations so 15*15 matrix with same logic above(a12 - 1,a23 - 1,a34 - 1 so on..). Thank you in advance and hope this explanation is understandable
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!