How to fix this error undefined function 'poly2sym ' for input arguments of type 'uint8'
显示 更早的评论
clear all;
close all;
clc;
disp('systematic encoder');
n=input('enter the value of n=');
k=input('enter the value of k=');
x=sym('x'); %create symbolicvariable of x
g=input('enter the coeff of generator polynomial');
gp=poly2sym(g); %converts numeric coeff to symbolic const
disp('generator polynomial g(x)=');
disp(gp);
b=2^k;
for i=0:b-1
disp(['sr no:',num2str(i+1)]);
disp('input data word');
d=bitget(uint8(i),4:-1:1);
mp=poly2sym(d);
disp('');
disp('message polynomial m(x)=');
disp(mp);
disp('');
y=x^(n-k)*mp;
disp('x^(n-k)*mp=');
disp(y);
z=sym2poly(y);
[q,r]=deconv(z,g);
ss=z+r;
cp=mod(ss,2);
disp('codeword is=');
disp(cp);
cx=poly2sym(cp);
disp('codeword polynomial c(x)=');
disp(cx);
disp('weight of polynomial');
wt=sum(nonzeros(cp));
end
dmin=n-k;
disp(['minimum hamming distance',num2str(dmin)]);
disp(['error detection capacity=',num2str(dmin-1)]);
disp(['error correction capability=',num2str((dmin-1)/2)]);
回答(1 个)
Walter Roberson
2020-3-21
mp = poly2sym( double(d) );
7 个评论
Shweta SONAWANE
2020-3-21
编辑:Shweta SONAWANE
2020-3-21
Walter Roberson
2020-3-21
What inputs should we use to test, and what outputs would be expected?
Shweta SONAWANE
2020-3-21
Shweta SONAWANE
2020-3-21
Walter Roberson
2020-3-21
The output I get for n=7 k=4 coefficients [1 1 0 1] is
error correction capability=1
I tested in your version, R2018b, in case there was something different in newer releases.
Shweta SONAWANE
2020-3-21
Walter Roberson
2020-3-21
After you run the code, please execute these and tell us the results:
class(dmin)
dmin
dmin-1
(dmin-1)/2
num2str((dmin-1)/2)
mod(dmin,1)
类别
在 帮助中心 和 File Exchange 中查找有关 Vector Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!