solving binary linear equation in matlab -
consider binary linear equation of form x*a = b
. want solve x, efficiency way avoiding using x = b*inv(a)
, instead using x= b/a
.but command results not in binary form. tried command x = mod(b/a ,2)
but still result not in binary. how fix this?
example `
x = 1 0 1 1 0 0 0 1 1 0`
and matrix
`0 1 0 1 0 0 1 1 1 1 0 1 1 1 1 1 1 1 0 1 0 0 1 0 1 1 0 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 0 0 1 1 0 0 0 0 0 1 1 1 0 1 1 0 1 0 0 0 1 1 0 0 0 1 0 0 1 1 1 1 0 1 0 1 1 1 1 0 1 0 1 1 1 0 1 1 1 1 1 0 0 0 1 1 0 0` full rank.
then
>> b = mod (x*a,2)
b =
1 0 1 1 1 0 1 0 1 1
to find x
, getting
>> k = b /
k =
columns 1 through 6
1.3750 -0.5000 -0.7500 -0.7500 0.8750 -0.5000
columns 7 through 10
1.8750 -0.5000 2.1250 -0.7500
or if using modulus 2, result is
>> k = mod (b / a,2)
k =
columns 1 through 6
1.3750 1.5000 1.2500 1.2500 0.8750 1.5000
columns 7 through 10
1.8750 1.5000 0.1250 1.2500
so ,how can x
in same binary form? , way matrices in class double not galois field
this example @ mathworks shows how perform boolean matrix inversion matlab , believe answers question.
i have not quite gotten working perfectly, believe need use combination of mod()
, logical()
example:
a=logical(a); b=(mod(x*a,2)); inversea= ~a; k=mod(b*inversea,2)
this gives
k=[1 1 0 0 1 1 0 1 0 0]
which not x, think if play around logical
function , logical operations in conjunction mod()
should able work
Comments
Post a Comment