How to find GF(2^m)
clc;
clear all;
close all;
x1='1100110011';
x2='1111001100';
y0='0000000000';
H ='1111011010'
yy= xor(y0-'0',x1-'0');
y1=gfmul(yy,H);
I got an error as this: Error using gfmul All inputs must be real integers.
Error in hash1 (line 11) y1=gfmul(yy,H);
What correction should i make?

댓글 수: 1

KSSV
KSSV 2017년 10월 23일
Read the doc here: https://in.mathworks.com/help/comm/ref/gfmul.html gfmul accepts double i.e matrix as input. You are inputting a string and logical which is not correct.

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

 채택된 답변

Guillaume
Guillaume 2017년 10월 23일

0 개 추천

It's not very clear what exactly you're intending to gfmul. If it's the two numbers that are represented by the binary pattern in yy and H (one being a vector of bits, the other a char array of bits), then maybe:
x1 = '1100110011';
x2 = '1111001100';
y0 = '0000000000';
H = '1111011010';
yy = xor(y0-'0',x1-'0');
y1 = gfmul(polyval(yy, 2), bin2dec(H));
polyval(b, 2) converts a vector of bits into the corresponding decimal value. bin2dec(s) converts a char array of bits into the corresponding decimal value. And as you already know, b = s - '0' (and s = char(b + '0')).

댓글 수: 4

Darsana P M
Darsana P M 2017년 10월 23일
Now the error is: Error using gfmul The input elements must be binary.
Is it because of the input? Actually the input when i check in command window is yy =
Columns 1 through 9
1 1 0 0 1 1 0 0 1
Column 10
1
And x1 =
1100110011
So the inputs are still different. What change must be done?
Darsana P M
Darsana P M 2017년 10월 24일
Actually now i understood the problem, in the above code:
clc;
clear all;
close all;
x1={'1' '1' '0' '0' '1' '1' '0' '0' '1' '1'};
X=cell2mat(x1);
x2={'0' '0' '0' '0' '0' '0' '0' '0' '0' '0'};
XX=cell2mat(x2);
yy= xor(X-'0',XX-'1');
y1 = gfconv(yy, [1 1 1 1 0 1 1 0 1 0],2);
In this line: y1 = gfconv(yy, [1 1 1 1 0 1 1 0 1 0],2); Now i get an error, saying the inputs arenot binary. But if I provide a matrix in place of yy as[1 0 1] y1 = gfconv([1 0 1], [1 1 1 1 0 1 1 0 1 0],2); Now i get an output.
But now my problem is, i want the XORed value to be given as input in gfconv() What should I do?
Guillaume
Guillaume 2017년 10월 24일
xor is a logical operator and hence return logical arrays. Converting that to double should resolve your problem (I don't have the comms toolbox):
y1 = gfconv(double(yy), [1 1 1 1 0 1 1 0 1 0],2);
Note that the doc says that if p is 2, you can use the normal operations conv and .*.
Darsana P M
Darsana P M 2017년 10월 24일
Yes now its correct. Thanks a lot.

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

추가 답변 (1개)

Walter Roberson
Walter Roberson 2017년 10월 23일

0 개 추천

y1 = gfmul(yy, bin2dec(H));

댓글 수: 2

Darsana P M
Darsana P M 2017년 10월 23일
Thanks. The above error mentioned s not there. But now the error is: Error using gfmul The inputs must have the same size and orientation.
Error in hash1 (line 11) y1 = gfmul(yy, bin2dec(H));
clc;
clear all;
close all;
x1='1100110011';
x2='1111001100';
y0='0000000000';
H ='1111011010'
yy= xor(y0-'0',x1-'0');
y1 = gfmul(yy, bin2dec(H));
Walter Roberson
Walter Roberson 2017년 10월 23일
gfmul needs three inputs, the third of which describes the galois field.

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

카테고리

도움말 센터File Exchange에서 Error Detection and Correction에 대해 자세히 알아보기

태그

질문:

2017년 10월 23일

댓글:

2017년 10월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by