I want to make a BER estimate of QPSK in AWGN with RS(240.224) as depicted in this paper. So I began with something working like the MATLAB example and I just made parameter changes as follows:
rng(1993); % Seed random number generator for repeatable results
M = 4; % Modulation order
bps = log2(M); % Bits per symbol
N = 240; % RS codeword length
K = 224; % RS message length
rsEncoder = comm.RSEncoder( ...
BitInput=true, ...
CodewordLength=N, ...
MessageLength=K);
rsDecoder = comm.RSDecoder( ...
BitInput=true, ...
CodewordLength=N, ...
MessageLength=K);
ebnoVec = (3:0.5:8)';
ebnoVecCodingGain = ...
ebnoVec + 10*log10(K/N); % Account for RS coding gain
errorStats = zeros(length(ebnoVec),3);
for i = 1:length(ebnoVec)
awgnChannel.EbNo = ebnoVecCodingGain(i);
reset(errorRate)
while errorStats(i,2) < 100 && errorStats(i,3) < 1e7
data = randi([0 1],1500,1);
encData = rsEncoder(data);
modData = pskmod(encData,M,InputType='bit');
rxSig = awgnChannel(modData);
rxData = pskdemod(rxSig,M,OutputType='bit');
decData = rsDecoder(rxData);
errorStats(i,:) = errorRate(data,decData);
end
end
berCurveFit = berfit(ebnoVecCodingGain,errorStats(:,1));
semilogy(ebnoVecCodingGain,errorStats(:,1),'b*', ...
ebnoVecCodingGain,berCurveFit,'c-')
ylabel('BER')
xlabel('Eb/No (dB)')
legend('RS coded BER','Curve Fit')
grid
I keep getting this error:
Error using comm.RSEncoder/setupImpl
the dimensions of the Input X must be consistent with the BitInput property value, the message and Codeword lengths, and primitive polynomial. ...
Your snippet is missing lines from the MATLAB example. The actual reference code is here: Estimate BER of QPSK in AWGN with Reed-Solomon Coding.
However, the key fix is data = randi([0 1],224*8,1);
Excerpt from help comm.RSEncoder/BitInput
:"When you set this property to true, X must be a column vector of bits with an integer multiple of MessageLength*M bits."
M = 8 in the case of your choice of (N,K) since you are using Galois Field GF(2^M). I would also recommend subtracting 3 from the SNR range ebnoVec = (0:0.5:5)';
so you have some bit errors at all of the SNRs or else berfit will return an curve that is not the same length as the simulation snr range.