error while using BCHencoder
7 次查看(过去 30 天)
显示 更早的评论
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
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
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" :
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Error Detection and Correction 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!