Hi @Jay,
After reviewing the documentation regarding rsenc function provided at the link below
https://www.mathworks.com/help/comm/ref/rsenc.html
The parameters n and k in the context of rsenc represent the codeword length and message length, respectively. The condition for n is that it should be of the form 2^m - 1 , where m ranges from 3 to 16. Here are the key points regarding m listed below.
Bits per Symbol
For m = 3, you can represent symbols as:
(000) (0), (001 ) (1), ... up to ( 111 ) (7)
This implies you can represent values between 0 and 2^m - 1.
Using Fewer Bits
If you want to use only 1 or 2 bits per symbol, Reed-Solomon codes, as defined in your context, won't support this directly as mentioned by @Walter Roberson and I do agree with his comments. Notice the minimum value for m is 3. To work with fewer bits, you would need a different coding scheme (like binary coding).
So, if you still wish to use Reed-Solomon codes then your message needs to be represented with binary symbols, consider the following approach; convert your binary data into a suitable format that fits within the constraints of Reed-Solomon encoding. For instance, you can group your binary data into blocks that correspond to the minimum symbol size allowed (i.e., groups of three bits). Here is an example code snippet that demonstrates how to encode a message of length 20 using Reed-Solomon codes with (m = 3).
% Define parameters m = 3; % Number of bits per symbol n = 2^m - 1; % Codeword length: n = 7 k = floor(20 / (2^m)); % Message length based on total bits available
% Create a binary message of length 20 binary_message = randi([0, 1], [1, 20]); % Random binary message
% Convert binary message to Galois field representation % Group into symbols based on m msg_symbols = zeros(1, k); for i = 1:k % Convert each group of three bits into a single symbol start_index = (i-1)*3 + 1; msg_symbols(i) = bi2de(binary_message(start_index:start_index+2)); end
% Create Galois field array msg = gf(msg_symbols, m);
% Generate RS codewords code = rsenc(msg, n, k);
% Display results disp('Original Binary Message:'); disp(binary_message); disp('Encoded Reed-Solomon Code:'); disp(code.x); % Display code in Galois field representation
Try implementing the code above. For more information on bit2int function, please refer to
https://www.mathworks.com/help/comm/ref/bit2int.html
Note: bit2int requires Communications Toolbox.
The above snippet code example assumes that the binary message can be effectively divided into groups that match the constraints of your chosen symbol size. Now, if you need to work exclusively with binary data without grouping into larger symbols, consider using simpler coding methods like Hamming codes or other forms of linear block codes that are designed for binary input.
This comprehensive approach should help you provide clarity on how to proceed with Reed-Solomon codes while addressing your requirement for binary messaging.
Please let us know if you have any further questions.