% Plot capacity of binary symmetric channel (BSC)

Np = 201;
p = linspace(0, 1, Np);
pp = p(2:Np-1);      % Skip p=0 and p=1
C(1) = 1;
C(Np) = 1;
C(2:Np-1) = 1 + pp.*log2(pp) + (1-pp).*log2(1-pp);

plot(p, C);
title('CAPACITY OF BINARY SYMMETRIC CHANNEL (BSC)')
xlabel('PROBABILITY OF BIT ERROR (p)')
ylabel('CAPACITY (bits/channel use)')
grid
