DES implementation in MATLAB faacing error in performing XOR operation

조회 수: 2 (최근 30일)
Dusk Devotee
Dusk Devotee 2022년 10월 30일
편집: Chris 2022년 11월 2일
hello everyone can any one please help me out?
i am performing XOR operation in MATLAB for cryptography i am a student
XOR function that i need to call in MAIN DES :
function c=XOR(a,b)
c=num2str(a'~=b')
error i get is :
Error using ~=
Matrix dimensions must agree.
Error in XOR (line 2)
c=num2str(a'~=b')
please someone help me out. Thankyou

답변 (1개)

Chris
Chris 2022년 10월 30일
편집: Chris 2022년 11월 2일
a and b apparently do not have the same number of characters. You can confirm this by displaying their sizes:
size(a)
size(b)
The sizes should be equal. If you want to pad a char vector with empty space, use concatenation.
a = [a, ' ']; %add two spaces to a row vector
b = [b; [' ']']; %add two spaces to a column vector: transpose before concatenating

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by