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)]);

Answers (1)

mp = poly2sym( double(d) );

7 Comments

Code runs but it won't give error correction capability I am attaching that output also
What inputs should we use to test, and what outputs would be expected?
We require to give value of n and k ie 7 and 4 and we have to give matrix[1 1 0 1] And at output we must get error correction capability as 1
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.
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)

Sign in to comment.

Products

Release

R2018b

Tags

Asked:

on 21 Mar 2020

Commented:

on 21 Mar 2020

Community Treasure Hunt

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

Start Hunting!