ber for bpsk modulation with selection diveristy in rayleigh channel

Upload: angela-fasuyi

Post on 28-Feb-2018

231 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/25/2019 Ber for Bpsk Modulation With Selection Diveristy in Rayleigh Channel

    1/2

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% All rights reserved by Krishna Pillai, http://www.dsplog.com% The file may not be re-distributed without explicit authorization% from Krishna Pillai.% Checked for proper operation with Octave Version 3.0.0% Author : Krishna Pillai% Email : [email protected]% Version : 1.0% Date : 6th September 2008% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    % Script for computing the BER for BPSK modulation in a% Rayleigh fading channel with selection diversity

    clearN = 10^6; % number of bits or symbols

    % Transmitterip = rand(1,N)>0.5; % generating 0,1 with equal probabilitys = 2*ip-1; % BPSK modulation 0 -> -1; 1 -> 0

    nRx = [1 2];Eb_N0_dB = [0:35]; % multiple Eb/N0 values

    for jj = 1:length(nRx)

    for ii = 1:length(Eb_N0_dB)

    n = 1/sqrt(2)*[randn(nRx(jj),N) + j*randn(nRx(jj),N)]; % white gaussiannoise, 0dB variance h = 1/sqrt(2)*[randn(nRx(jj),N) + j*randn(nRx(jj),N)]; % Rayleigh channel

    % Channel and noise Noise addition sD = kron(ones(nRx(jj),1),s); y = h.*sD + 10^(-Eb_N0_dB(ii)/20)*n;

    % finding the power of the channel on all rx chain hPower = h.*conj(h);

    % finding the maximum power [hMaxVal ind] = max(hPower,[],1); hMaxValMat = kron(ones(nRx(jj),1),hMaxVal);

    % selecting the chain with the maximum power ySel = y(hPower==hMaxValMat); hSel = h(hPower==hMaxValMat);

    % equalization with the selected rx chain

    yHat = ySel./hSel; yHat = reshape(yHat,1,N); % just to get the matrix dimension proper

    % receiver - hard decision decoding ipHat = real(yHat)>0;

    % counting the errors nErr(jj,ii) = size(find([ip- ipHat]),2);

    end

  • 7/25/2019 Ber for Bpsk Modulation With Selection Diveristy in Rayleigh Channel

    2/2

    endsimBer = nErr/N; % simulated berEbN0Lin = 10.^(Eb_N0_dB/10);theoryBer_nRx1 = 0.5.*(1-1*(1+1./EbN0Lin).^(-0.5));theoryBer_nRx2 = 0.5.*(1-2*(1+1./EbN0Lin).^(-0.5) + (1+2./EbN0Lin).^(-0.5));

    % plotclose allfigure

    semilogy(Eb_N0_dB,theoryBer_nRx1,'bp-','LineWidth',2);hold onsemilogy(Eb_N0_dB,simBer(1,:),'mo-','LineWidth',2);semilogy(Eb_N0_dB,theoryBer_nRx2,'rd-','LineWidth',2);semilogy(Eb_N0_dB,simBer(2,:),'ks-','LineWidth',2);axis([0 35 10^-5 0.5])grid onlegend('nRx=1 (theory)', 'nRx=1 (sim)', 'nRx=2 (theory)', 'nRx=2 (sim)');xlabel('Eb/No, dB');ylabel('Bit Error Rate');title('BER for BPSK modulation with Selection diveristy in Rayleigh channel');