%
% Function 9.3 : "cp0901_MUIBER_2PPM"
%
% Evaluates the theoretical probability of error
% for a 2PPM system in AWGN channels under the
% Standard Gaussian Approximation
%
% 'ebno' is a vector containing the values in dB of the % ratio Eb/No
% 'erx0' is the energy of the useful signal
% 'erxMUI' is a vector containing the received energies
% of the
% interfering users.
% 'pulse' is the waveform of the basic pulse
% 'Rb' is the user bit rate [b/s]
% 'PPMshift' is the value of the PPM shift [s]
% 'fc' is the sampling time [Hz]
% 'gamma_r' represents the ratio (Ts/(Tb/Ns))
%
function [BER] = cp0901_MUIBER_2PPM(ebno,erx0,erxMUI,...
pulse,Rb,PPMshift,fc,gamma_r)
% ----------------------------------------------------
% Step One - Evaluation of the required constant terms
% ----------------------------------------------------
% R0(epsilon) [R]
dt = 1 / fc; % sampling period
PPM_samples = floor(PPMshift/dt);
pulse_samples = length(pulse);
Ep = sum((pulse.^2).*dt);
pulse = pulse./sqrt(Ep); % energy normalization
p0 = zeros(1,PPM_samples+pulse_samples);
p0(1:length(pulse)) = pulse;
p1 = cp0804_signalshift(p0,fc,PPMshift);
R = sum((p0.*p1).*dt);
% (Sigma_m)^2 [sm2]
sm2 = cp0901_sm2_PPM(pulse,PPMshift,fc);
% MUI energy summation [EMUI]
EMUI = sum(erxMUI./erx0);
% -------------------------------------
% Step Two - Evaluation of SIR and SNRn
% -------------------------------------
SIR = (((1-R)^2)*gamma_r)/(sm2*Rb*EMUI);
EBN0 = 10.^(ebno/10);
SNRn = EBN0.*(1-R);
% -----------------------------------
% Step Three - Performance evaluation
% -----------------------------------
SNRref = 1./((1./SNRn)+(1/SIR));
BER = 0.5.*erfc(sqrt(SNRref./2));