I understand that you are interested in how transmission is handled when the data length is not a multiple of the bits per symbol in qammod.
I have reviewed your issue, and here is how we can proceed to resolve it:
- When using 64-QAM, we transmit bits per symbol.
- If we generate data consisting of only 61 bits, we need to apply padding to ensure the data length is a multiple of 6. This is done by calculating the necessary padding as follows:
bitsPerSym = log2(M);
numBits = length(x);
paddingBits = bitsPerSym - mod(numBits, bitsPerSym);
- In this scenario, the required padding is calculated as We add these 5 padding bits as zeros, proceed with the transmission as usual, and then remove the padding bits at the end.
Here is the MATLAB implementation of the scenario described above.
M = 64;
bitsPerSym = log2(M);
x = randi([0 1], 61, 1);
% Calculate padding required
numBits = length(x);
paddingBits =bitsPerSym - mod(numBits, bitsPerSym);
% Pad the data
x_padded = [x; zeros(paddingBits, 1)];
% Modulation & Demodulation
y = qammod(x_padded, M, 'bin', 'InputType', 'bit', 'OutputDataType', numerictype(1,16,10));
z_padded = qamdemod(y, M, 'bin', 'OutputType', 'bit');
% Remove padding
z = z_padded(1:numBits);
s = isequal(x, double(z))
Refer to the following MathWorks documentation for qammod and qamdemod respectively.
- https://www.mathworks.com/help/comm/ref/qammod.html
- https://www.mathworks.com/help/comm/ref/qamdemod.html
I hope this addresses your question.