I am trying to multiply a hexdecimal value AA
by 2 in the galois field using the gfconv(a,b)
function of Matlab, the console returns to me an error saying: "The input elements must be binary.", but my two elements are binary
a=hexToBinaryVector('AA');
b=de2bi(2);
c=gfconv(a,b);
disp(c);
The error code:
Error using gfconv_mex
The input elements must be binary.
Error in gfconv (line 120)
c = gfconv_mex(varargin{:});
Error in test(line 3)
c=gfconv(a,b);
Any idea how to solve that?
I'm not doing all the code here, but here's the steps that I would take to solve it.
Problem
It's in binary form, but b
is a vector of binary numbers.
Solution
Try that and see if it works.
Note - Expansion of step 3:
if we have variable a = '[0+11]';
, we can select individual characters from the string like:
a(3)
ans = '+'
a(4)
ans = '1'
a(1)
and = '['
Therefore, you can parse the string with a loop"
for n = 1 : length(a)
if a(n) == '1' || a(n) == '0'
str(n) = a(n);
end
end
Finally, convert the string:
num = str2num(str);
done