06.06.2022 Views

B. P. Lathi, Zhi Ding - Modern Digital and Analog Communication Systems-Oxford University Press (2009)

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

11 . 9 MATLAB Exercises 661

Eb2N_num=10 A (Eb2N(i) /10) ;

% Eb/N in numeral

Var_n=Lc/(2*Eb2N_num) ;

%1/SNR is the noise variance

signois=sqrt (Var_n) ;

% standard deviation

awgnois=signois*noiseq ;

% AWGN

% Add noise to signals at the channel output

y_out=x_in+awgnois;

Y_out=reshape (y_out ,Lc,Ldata) .'; clear y_out awgnois;

% Despread first and apply decorrelator Rinv

z_out= (Y_out*pcode );

% despreader (conventional ) output

clear Y_out ;

z_dcr=z_out*Rinv;

% decorrelator output

% Decision based on the sign of the single receivers

decl=sign (real ( z_out) )+j*sign ( imag ( z_out) );

dec2=sign (real ( z_dcr) )+j*s ign ( imag ( z_dcr) );

% Now compare against the original data to compute BER of user 2

% and user 4 (weaker ones) .

BERa2= [BERa2 ;sum ( [real (data_sym( : ,2) )~=real (decl (:,2) ) ; ...

imag ( data_sym (:,2) )~=imag (decl (:,2 ))])/ (2*Ldata) J ;

BERa4= [BERa4 ;sum ( [real (data_sym( : ,4) )~=real (decl (:,4) ) ; ...

imag ( data_sym (:,4) )~=imag (decl (:,4) ) ] )/(2 *Ldata) J ;

BERb2 =[BERb2 ;sum ( [real (data_sym( : ,2) )~=real (dec2 (:,2)) ; ...

imag ( data_sym (:,2) )~=imag (dec2 (:,2)) ] )/(2 *Ldata) J ;

BERb4= [BERb4 ;sum ( [real (data_sym( : ,4))~=real (dec2 (:,4) ) ; ...

imag ( data_sym( :,4 ))~=imag (dec2 (:,4 ))])/ (2*Ldata) ] ;

BER_az= [ BER_az ;0.S*erfc ( sqrt (Eb2N_num ) )];

%analytical

end

figure (l)

figber=semil ogy (Eb2N, BER_az , 'k~' ,Eb2N, BERa2 , 'k~o ' ,Eb2N,BERa4 , ' k~s', ...

Eb2N, BERb2 , 'k~~o' ,Eb2N, BERb4 , 'k--s');

legend('Single~user (analysis)', 'User 2 (single user detector) ', ...

'User 4 (single user detector) ', 'User 2 (decorrelator) ', ...

'User 4 (decorrelator) ')

axis ( [ 0 12 0.99e-5 1.e0] );

set ( figber , 'LineWidth ' , 2) ;

xlabel ('E_b /N (dB) ') ;ylabel ('QPSK bit error rate ')

title ('Weak~user BER comparisons ');

We also implement the decision feedback MUD of Sec. 11.7 in MATLAB program Exl 1_ 4b . m.

The decision feedback MUD performance of the two users is shown in Fig. 11.27.

% MATLAB PROGRAM <Exll 4b .m>

% This program provides simulation for multiuser CDMA

% systems . The 4 users have different powers to illustrate the

% near-far effect in single user conventional receivers

%

% Decision feedback detectors are tested to show its

% abi lity to overcome the near~far problem .

%

%clear;clf

Ldata=l00000;

Lc=31;

%User number = 4;

% Generate QPSK modulation symbols

% data length in simulation; Must be divisible by 8

% spreading factor vs data rate

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!