How to solve the code}

1 回表示 (過去 30 日間)
Darsana P M
Darsana P M 2017 年 10 月 23 日
コメント済み: Darsana P M 2017 年 10 月 24 日
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 日
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 件のコメント
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 日
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.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeError Detection and Correction についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by