06.06.2022 Views

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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

11.9 MATLAB Exercises 655

% Add jamming sinusoid sampling frequency is fc = Le

jam_mod=kron (jam_data,ones (Lc,1 )); clear jam_data;

jammer= sqrt (Pj/2)*jam_mod .*exp (j *2*pi*0.12* (1:Ldata*Lc) ).'; %fj/fc=0 .12.

clear jam_mod;

[P,x] =pwelch (x_in, [] , [] , [4096] ,Le , 'twoside');

figure (1) ;

semil ogy (x-Lc/2, fftshift (P) );

axis ([-Lc/2 Lc /2 l.e-2 l.e2] );

grid;

xfont=xlabel ('frequency (in unit of 1/T_s ) ');

yfont=ylabel ('CDMA signal PSD' );

set (xfont , 'FontSize' , 11) ;set (yfont , 'FontSize' ,11) ;

[P,x] =pwelch (jammer+x_in, [] , [] , [4096] ,Le , 'twoside' );

figure (2) ;semi logy (x-Lc/2, fftshift (P));

grid;

axis ([-Lc/2 Lc/2 l.e-2 l.e2] );

xfont=xlabel ('frequency (in unit of 1/T_s ) ');

yfont=ylabel ('CDMA signal + narrowband jammer PSD' );

set (xfont, 'FontSize' , ll) ;set (yfont, 'FontSize ' , 11) ;

BER=[];

BER_az= [];

for i=l:10,

Eb2N (i) = (i-1) ;

%(Eb/N in dB )

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+jammer;

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

% Despread first

z_out=Y_out*pcode ;

% Decision based on the sign of the samples

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

% Now compare against the original data to compute BER

BER= [BER;sum ( [real (data_sym) ~=real (decl) ; ...

imag ( data_sym) -=imag (decl)])/(2*Ldata) ];

BER_az= [ BER_az ;0.5*erfc ( sqrt (Eb2N_num ) )];

%analytical

end

figure (3)

figber=semi logy (Eb2N, BER_az, 'k-',Eb2N,BER, 'k- o' ) ;

legend ('No jamming ','Narrowband jamming (-10 dB ) ');

set ( figber , 'LineWidth ' , 2) ;

xfont=xlabel ('E_b/N (dB) ');

yfont=ylabel ('Bit error rate');

title ('DSSS (CDMA ) wi th spreading gain 11' ) ;

Because the spreading factor in this case is L = 11, the DSSS signal occupies a bandwidth approximately

11 times wider. From the user signal carrier, we add a narrowband QPSK jamming signal with a

carrier frequency offset of 1.32/T. The signal-to-interference ratio (SIR) can be adjusted. In Fig. 11.23,

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

Saved successfully!

Ooh no, something went wrong!