Modulo-2 matrix multiplication

조회 수: 14 (최근 30일)
Ronald Niwamanya
Ronald Niwamanya 2021년 5월 5일
댓글: Dyuman Joshi 2021년 5월 5일
Hi.
I would like to know whether its possible to have the following multiplication and how it can be perfromed.
a=[1 1];
b=[0 0];
c=[1 0];
X=[a b c];
Y=[1 1 0;1 0 1; 0 1 0];
Z=mod(X*Y, 2);
I am expecting Z=[a+b,a+c,b], the addition is modulo-2 addition. The final output should be Z=[110100];
Thank you.

채택된 답변

Dyuman Joshi
Dyuman Joshi 2021년 5월 5일
size(X) = [1 6];
size(Y) = [3 3];
X and Y are not compatible for multiplcation given their sizes.
You can do something like this -
X = [a;b;c]; %size(X) = [3 2]
Z = mod(Y*X,2);
Z = [1 1; 0 1; 0 0];
Z = reshape(Z,1,[]);
Z = [1 1 0 1 0 0]; %If you want it to be a number and not an array, use polyval(z,10)
  댓글 수: 2
Ronald Niwamanya
Ronald Niwamanya 2021년 5월 5일
needed to add transpose on Z, (Z = mod(Y*X,2)') . Thank you very much.
Dyuman Joshi
Dyuman Joshi 2021년 5월 5일
If my answer helped you solve your problem, kindly accept it!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Scatter Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by