www.gusucode.com > MPSK,误码率性能仿真源码程序 > MPSK,误码率性能仿真源码程序/IET_MATLAB/functions/ber_msd.m

    % computing BER of MSD 
% paper by D. Divsalar, paper by Paul Ho,Paper by Zieler
function Pb=ber_msd(P0,A2,N0,M,N,fsr,frd,ch_dis,sig_1,sig_2,c)

% sum of Hamming distances
if M==2
    if N==2
        w_u=1;
    else
        w_u=2*(N-1);
    end
else 
    if N==2
        w_u=2;
    else 
        w_u=4*(N-1);
    end
end

sigman2=(1+A2*sig_2)*N0;

% Double-Rayleigh fading autocorrelation function, Jakes model
k=0:ch_dis:(N-1)*ch_dis;
phi=A2*P0*sig_1*sig_2*besselj(0,2*pi*fsr*k).*besselj(0,2*pi*frd*k);

% Correlation matrix C=E{hh'}+sigma2*I is a Toeplitz matrix
Rh=toeplitz(phi)+sigman2*eye(N);

% v should be even
v=64;

sum_k1tov=0;
for k=1:v/2
    tau_k=tan((2*k-1)*pi/(2*v));
    
    % transmitted symbols
    Ax=diag(ones(1,N));
    % detected symbols
    Axp=diag([ones(1,N-1),exp(1i*2*pi/M)]);
        
    Q=-(Ax*Rh^(-1)*Ax'-Axp*Rh^(-1)*Axp');
    Cy=Ax*Rh*Ax';
    
    s=c+1i*c*tau_k;
    phi_d=1/det(eye(N)+s*Cy*Q);
    sum_k1tov=sum_k1tov+c*real(phi_d)+tau_k*imag(phi_d);
end

% pair-wise
Px_xh=1/v*sum_k1tov;

% upper bound
Pb=-1/(log2(M)*(N-1))*w_u*Px_xh;

end