Code covered by the BSD License

# Reed Solomon Figures: Follow along with Sklar

### Colin O'Flynn (view profile)

Code to calculate several figures around Reed Solomon code.

fig2.m
```%Copyright Colin O'Flynn
%Recreates figure 2 from
%
%"Bit error probability versus Eb/N0 performance of several n = 31, t-error
% correcting Reed-Solomon coding systems with 32-ary MFSK modulation over
% Systems, ed. Thomas C. Bartee, Howard W. Sams Company, Indianapolis,
% Ind., 1985, p. 312. Originally published in J. P. Odenwalder, Error
% Control Coding Handbook, M/A-COM LINKABIT, Inc. San Diego, Calif.,
% July 15, 1976, p. 92.)"
%
% Same as figure 8.2 in Sklar's Digital Communications book

m = 5;
trange = [1 2 4 8];
spec = {'-', '--', ':', '-.'};
ebNodB = 3.5:0.1:7.0;
ebNo = 10 .^ (ebNodB ./ 10);
q=1;
for t=trange
i = 1;
for eb = ebNo

%We measure information bits in Eb/No only
n = 31;
k = n-2*t;

eb = k/n * eb;

%Find p of FSK alone
%5.4-46: Proakis, J. G., Digital Communications, 4th ed., McGraw-Hill,
%8.66: Simon, M. K., and Alouini, M. S., Digital Communication over Fading Channels  A Unified Approach to Performance Analysis, 1st ed., Wiley, 2000.
p = 0;
M=32;
for r=1:M-1
p = p + (-1)^(r+1) * nchoosek(M-1,r) * (1 / (r+1)) * exp((-r / (r+1))*log2(M)*eb);
end

%p now has channel symbol error probability

%Pass that onto RS coding
sum = 0;
for j=(t+1):(2^m - 1)
sum = sum + j* nchoosek(2^m-1, j) * p^j * (1-p)^(2^m - 1 - j);
end
pe = 1/(2^m - 1) * sum;

pb(i) = pe * (2^(m - 1)) / (2^m - 1);
i = i + 1;
end
semilogy(ebNodB, pb, spec{q});
hold on
q=q+1;
end
axis([3.5 7.0 1E-7 1E-2])

xlabel('E_b/N_0 (dB)');
ylabel('Bit error probability, P_B');
title('Figure 2 from Handout');
legend('t=1', 't=2', 't=4', 't=8');```