| 1 | function theoreticalPSK(EbN0_db, M, varargin) |
| 2 | %% Plot theoretical curve |
| 3 | EbN0 = 10 .^ (EbN0_db ./ 10); |
| 4 | if M == 2 || M == 4 |
| 5 | %% BPSK: bit error when noise Nr > sqrt(Eb) |
| 6 | %% Pr(Nr > sqrt(Eb)) |
| 7 | %% = Pr(Z > sqrt(Eb) / sqrt(N0/2)) |
| 8 | %% |
| 9 | %% QPSK = 2 BPSKs, one real and one imaginary, each with one bit |
| 10 | %% so BER is the same as BPSK (assuming Gray code) |
| 11 | ber_th = qfunc(sqrt(2 * EbN0)); |
| 12 | semilogy(EbN0_db, ber_th, varargin{:}); |
| 13 | else |
| 14 | %% Approximation: J.G. Proakis and M. Salehi, 2000, Contemporary |
| 15 | %% Communication Systems using MATLAB (Equations |
| 16 | %% 7.3.18 and 7.3.19), Brooks/Cole. |
| 17 | ber_ap = 2 * qfunc(sqrt(EbN0 * log2(M) * 2) * sin(pi / M)) / log2(M); |
| 18 | semilogy(EbN0_db, ber_ap, varargin{:}); |
| 19 | end |
| 20 | end |