Error: Error using fec.bchdec/decode. The number of rows in CODE must be an integer multiple of N.
Mostrar comentarios más antiguos
Hi Guys, I try to create the script of Cyclic Redundancy Check(CRC-4) with BCH code. I got the error of "Error: Error using fec.bchdec/decode. The number of rows in CODE must be an integer multiple of N." on the following line:
decodedata1 = decode(bchd,codeword1);
Half of the script at the transmitter and receiver are as follows:
crcGen = comm.CRCGenerator('z4+z3+z2+z+1'); %CRC-4
crcDet = comm.CRCDetector('z4+z3+z2+z+1');
bch=fec.bchenc(7,4);
bchd= fec.bchdec(bch);
%#######At the Transmitter########
dataIn1=double(rand(1,N)>0.5);
symbols1=unique(dataIn1);
probs1 = histc(dataIn1,symbols1)./numel(dataIn1); % Generation of data for user1
[dict1, avglen1] = huffmandict(symbols1, probs1);
encData1 = huffmanenco(dataIn1,dict1);
if mod(size(encData1,1),4)==0
encBCH1 = encode(bch,encData1');
else
le=mod(size(encData1,1)*size(encData1,2),4);
le1=4-le;
encData1=[encData1,zeros(1,le1)];
h=fec.bchenc(7,4);
encBCH1 = encode(bch,encData1');
end
encCRC1 = step(crcGen,encBCH1);
Data_BPSK1 = 2*encBCH1-1; % BPSK modulation 0 -> -1; 1 -> 0
%#######At the Receiver########
recdata12=real(recdata11)>0;
[codeword1,frmError1(i)] = step(crcDet,recdata12.');
codeword1=double(codeword1);
decodedata1 = decode(bchd,codeword1);
errors_user1(i) = size(find([dataIn1- decodedata1]),2); %Errors for User1
SBer1 = errors_user1/N;
Thank You.
Respuestas (0)
Categorías
Más información sobre Communications Toolbox en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!