BInary matrix multiplication
Mostrar comentarios más antiguos
Hii,
I am trying to multiply two matrices defined as follows:
U = [1 1 1 1 0 0 0 0 0 1 1];
G = [0 1 0 1 1 0 0 0 0 0 0 0 0 0 0
0 0 1 1 0 1 0 0 0 0 0 0 0 0 0
0 1 1 0 0 0 1 0 0 0 0 0 0 0 0
0 1 1 1 0 0 0 1 0 0 0 0 0 0 0
1 0 0 1 0 0 0 0 1 0 0 0 0 0 0
1 0 1 0 0 0 0 0 0 1 0 0 0 0 0
1 0 1 1 0 0 0 0 0 0 1 0 0 0 0
1 1 0 0 0 0 0 0 0 0 0 1 0 0 0
1 1 0 1 0 0 0 0 0 0 0 0 1 0 0
1 1 1 0 0 0 0 0 0 0 0 0 0 1 0
1 1 1 1 0 0 0 0 0 0 0 0 0 0 1];
Here U is a matrix of size 1*11 whereas G is a matrix of size 11*15. I have no idea of how to do binary multiplication any suggestions in this regard??
Thanks for you help.
Respuestas (1)
Walter Roberson
el 15 de Abr. de 2012
0 votos
You can see binary matrix multiplication code at http://www.mathworks.com/matlabcentral/answers/16192-inversion-of-a-boolean-matrix
7 comentarios
Dyno
el 15 de Abr. de 2012
Dyno
el 15 de Abr. de 2012
Walter Roberson
el 15 de Abr. de 2012
See Derek's MMBool routine in the above Question.
NGUYEN Duy Ngan
el 29 de Abr. de 2014
Thank you very much Dyno.
Chris Volpe
el 23 de Ag. de 2016
The "mod 2" part is appropriate only if boolean addition is defined as an exclusive-or operation. In most contexts it should be ordinary "or". I would do this as:
V = logical(double(U)*double(G))
Onyekachi Ukeje-Eloagu
el 1 de Oct. de 2016
I tried using the "mod 2" and "logical" with some problems I am working on. I am not sure what you are referring to when you talk about the boolean addition being defined as an exclusive-or, but the "mod 2" gives the correct answer and "logical" does not
Walter Roberson
el 1 de Oct. de 2016
Onyekachi Ukeje-Eloagu: in your situation, should boolean 1+1 be equal to 1 ("or") or should it be equal to 0 ("exclusive or") ?
Categorías
Más información sobre Resizing and Reshaping Matrices 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!