필터 지우기
필터 지우기

error while using BCHencoder

조회 수: 5 (최근 30일)
As_rar
As_rar 2020년 11월 8일
편집: Pooja Kumari 2024년 1월 15일
Hello everyone
I would ask about BCHencoder ..
I use BCHencoder from communication toolbox , as in https://www.mathworks.com/help/comm/ref/comm.bchencoder-system-object.html
and this error come to me
Error using comm.BCHEncoder/setParameters
N and K must be positive, double precision integer scalars
all k and n are integers
this is my code
ds=randi([0 1],18,1); %generating a random string
enc = comm.BCHEncoder(20,18); %creating Object of BCH encoder (ECC: error corecting code)
c=step(enc,ds);
the error come from " step(enc,ds)"
i use matlab 2020b
could anyone help me how to fix the error
thank you so much
  댓글 수: 1
Jorge Cadena
Jorge Cadena 2021년 9월 29일
I have the same issue and no idea how to resolve it. Were you able to find a solution?

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

답변 (1개)

Pooja Kumari
Pooja Kumari 2024년 1월 15일
편집: Pooja Kumari 2024년 1월 15일
Hi,
As per my understanding, you are facing "Error using comm.BCHEncoder/setParameters N and K must be positive, double precision integer scalars" error because value of "N" and "K" are not of correct data type or value.
The value of codeword length which is represented by "N" must take the form (2^m – 1), where m is an integer in the range [3, 16]. The message length which is represented by the "K" parameter should follow this condition that "N > K" and both should be integers.
Value of "M" which is given as "20" does not satisfy 2^m-1 property.
Example code for BCHEncoder:
% Define BCH code parameters
n = 15; % Codeword length
k = 5; % Message length
% Create BCH encoder and decoder objects
bchEncoder = comm.BCHEncoder('CodewordLength', n, 'MessageLength', k);
bchDecoder = comm.BCHDecoder('CodewordLength', n, 'MessageLength', k);
msg = randi([0 1], k, 1); % message signal
encodedMsg = step(bchEncoder, msg); % Encoding message signal
% Introduce errors
receivedMsg = encodedMsg;
errorPositions = [3, 7]; % Example error positions
receivedMsg(errorPositions) = ~receivedMsg(errorPositions); % Flip bits to introduce errors
[decodedMsg, errorStats] = step(bchDecoder, receivedMsg); %decoded message signal
% Find error locations by comparing the original encoded message and the received message
errorLocations = find(encodedMsg ~= receivedMsg);
You can refer to the documentation for more information on "BCHEncoder" :

카테고리

Help CenterFile Exchange에서 Error Detection and Correction에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by