Bit wise operation of And and XOR together

조회 수: 1 (최근 30일)
Dhruv Bhatnagar
Dhruv Bhatnagar 2020년 11월 21일
편집: Dhruv Bhatnagar 2020년 11월 24일
f10 = 1 + v2 + x2 + x2v2 + x2v3 + x3v2 + x2w2 + x2w3 + x3w2
these are the expressions and I want to perform xor and AND operation on this for 2^8 combination in binary
And if this not correct method then how can I write this expression such that it gives 1bit output as either 0 or 1 for 2^8 combination
function a=Share1(u2,v2,w2,x2,u3,v3,w3,x3)
a=bitxor(1,v2,x2,bitxor(bitand(x2,v2),bitand(x2,v3),bitand(x3,v2),bitand(x2,w2),bitand(x2,w3),bitand(x3,w2)));
end
But it is not working.
Please someone suggest how can I write this qudratic equation using MATLAB or where I am wrong
  댓글 수: 2
dpb
dpb 2020년 11월 21일
Can you explain what the expression as written means?
Mathematically it looks like a simple sum of products of three variables [v,w,x] for two conditions.
Why then write a function with four variables [u,v,w,x] where it appears they correspond to the single/product terms and the result would just be the sum (plus the constant 1) of course?
Certainly seems no reason for bitwise operations here.
Dhruv Bhatnagar
Dhruv Bhatnagar 2020년 11월 22일
편집: Dhruv Bhatnagar 2020년 11월 22일
these two are the expressions and I want to perform xor and AND operation on this for 2^8 combination in binary which results in 1 bit output as either 0 or 1. And then comparing result that (number of 0 == number of 1) or not.
And if this not correct method then how can I write this expression such that it gives 1bit output as either 0 or 1 for 2^8 combination
Thank You.

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

답변 (2개)

Setsuna Yuuki.
Setsuna Yuuki. 2020년 11월 21일
The binary operation is between two values logics or values of 0's and 1's. In your code some logics operation are done between three logics values.
For example:
bitxor(bitand(x2,w2),bitand(x2,w3),bitand(x3,w2)) % bitxor(l1,l2,l3)
bitxor(bitxor(bitand(x2,w2),bitand(x2,w3)),bitand(x3,w2)) % bitxor(bitxor(l1,l2),l3)
  댓글 수: 1
Dhruv Bhatnagar
Dhruv Bhatnagar 2020년 11월 22일
if it used for 256 inputs then how to apply

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


Bruno Luong
Bruno Luong 2020년 11월 21일
편집: Bruno Luong 2020년 11월 21일
Z=quad(0,1,1,0,1,0,1,1)
function F10 = quad(u2,v2,w2,x2,u3,v3,w3,x3)
% note: u2 and u3 not used anywhere
F10=1+v2+x2+x2*v2+x2*v3+x3*v2+x2*w2+x2*w3+x3*w2;
F10=mod(F10,2);
end
  댓글 수: 2
Dhruv Bhatnagar
Dhruv Bhatnagar 2020년 11월 22일
It is not giving output I edit my question back if you can suggest something based on that then please
Thank You
Bruno Luong
Bruno Luong 2020년 11월 22일
"It is not giving output "
It gives 0 for me.
>> testquad
Z =
0

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by