HOW TO XOR NEGETIVE DECIMAL NUMBER?

조회 수: 2 (최근 30일)
Al Anher Provat
Al Anher Provat 2022년 8월 9일
댓글: Walter Roberson 2022년 8월 10일
My original image size 256*256. I have performed transformation, then i divided the matrix into 4*4 block, then i performed decomposition on each block...output of decomposition was P ans S matrix...i shuffled the elements of p..but now i want to perform xor with s. but my problem is i need to xor a key with s matrix which contain negetive decimal number .. but it showing me error ..
for i=1:16
bi=xor(Dec2bin(smod(i)),Dec2bin(finalkey(i)));
s1(i)= Binary2Dec(bi);
end
  댓글 수: 2
James Tursa
James Tursa 2022년 8월 9일
편집: James Tursa 2022년 8월 9일
What are the variable types of smod and finalkey? Can you post a small subset of example data?
Al Anher Provat
Al Anher Provat 2022년 8월 10일
Smod contains positive+negative double and final key contains decimal number actually.

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

답변 (1개)

Walter Roberson
Walter Roberson 2022년 8월 9일
편집: Walter Roberson 2022년 8월 10일
for i=1:16
S = dec2bin(typecast(double(smod(i)), 'uint8'), 8) - '0');
F = dec2bin(typecast(double(finalkey(i)), 'uint8'), 8) - '0'));
bi = xor(S, F);
s1(i) = typecast(uint8(bin2dec(char(bi + '0'))), 'double');
end
  댓글 수: 4
Walter Roberson
Walter Roberson 2022년 8월 10일
I have no idea what your Dec2Bin function is.
dec2bin has accepted a second parameter for at least the last 5 years.
Walter Roberson
Walter Roberson 2022년 8월 10일
Why? Why are you not using dec2bin() ?

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by