Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

246
Page 1 of 246 Solutions Manual to Introduction to Wireless Systems P. M. Shankar Drexel University

Transcript of Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

Page 1: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 1/246

Page 1 of 246

Solutions Manual

to

Introduction to Wireless Systems

P. M. Shankar

Drexel University

Page 2: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 2/246

Page 2 of 246

The solutions manual contains the m-files, charts, graphs, and numerical values for the problemsin the book. The m-files have comment statements making it easy for the reader to understandthe programs. Some of the programs are a little bit too long and can be shortened if necessary.

Since the book grew out of my course offered from 1997, a few of the m-files are based onMATLAB 5. Most of the m-files, however, use MATLAB 6 and therefore may be a bit shorterand more efficient. Statistics and Signal Processing Toolboxes have been used extensively.

Imaging Processing Toolboxes and Communication toolbox have been used sparingly.

Every effort has been made to ensure that errors are minimized. If you do find an error, I wouldgreatly appreciate if you could notify me.

Sincerely

P. M. ShankarSeptember 4, 2001

Page 3: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 3/246

Page 3 of 246

Chapter 2 ......................................................................................................................................... 4

Chapter 3 ....................................................................................................................................... 68Chapter 4 ..................................................................................................................................... 164

Chapter 5 ..................................................................................................................................... 181Chapter 6 ..................................................................................................................................... 221

Page 4: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 4/246

Page 4 of 246

Chapter 2

Problem 1 Powerlawprofiles.m

clear

%powerlawprofiles.m; calculates the powerloss as per inverse square law and 1/d^n.close all

nu=[2 3 3.5 4];%four values of the loss parameterfor k=1:4;

n=nu(k);

d=1:50;% distance in Kmd1=d.^n;

dn=1./d1;pn=-10.*log10(dn);%inverse lawplot(d,pn,'k');

xlabel('distance in Km');ylabel('powerloss in dB');

hold onend;

Page 5: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 5/246

Page 6: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 6/246

Page 6 of 246

plot(d,asub);

%axis([1 30 -140 -60]);

xlabel('distance Km');ylabel('power loss dB');

title('suburban');

subplot(2,2,4);

plot(d,arur);

%axis([1 30 -140 -60]);

xlabel('distance Km');ylabel('power loss dB');

title('rural');

%loss at a reference distance of 100 m

Wave=3e8/900e6;%wavelength in metersPL=10*log10((4*pi*100)^2/Wave^2);%relative loss at 100 meters

d3=d(3)*1000;%distance in meters%use eqn. (2.19)denom=10*log10(d3/100);%denominator of eqn. (2.19)

nuLarge=(alar(3)-PL)/denom%nu for large citynuMed=(amed(3)-PL)/denom%nu for med city

nuSub=(asub(3)-PL)/denom%nu for suburbs citynuRur=(arur(3)-PL)/denom%nu for rural city

Page 7: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 7/246

Page 7 of 246

νLarge = 4.1865 νMed = 4.1801

νSub =3.4159

νRur =1.9890

Problem 5.fadcom.m

clear%fadcom.m simulates Doppler fading including a carrier frequency and then demodulate%uses random phase model for both Rayleigh and Rician fading

% also computes the outage probabilityfc=900e3;%carrier frequency

ppf=2*pi*fc;N=11;% Number of mutiple pathsfd=input('enter the Doppler shift...')

ppw=2*pi*fd;%scattering strengths are considered to be Gamma distributed

Page 8: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 8/246

Page 8 of 246

fs=4*fc;%sampling rate

Ts=1/fs;t = [0:Ts:1999*Ts]; %time array

nn=length(t);ci=zeros(1,nn); %received signal (Rayleigh

for m=1:N;a = gamrnd(1.4,1,1,nn);ppwt=ppw*unifrnd(0,2*pi,1,nn);

ci = ci + a.*cos((ppf+ppwt).*t+ppwt+unifrnd(0,2*pi,1,nn));end;cr=ci;

crr=ci+2*cos(ppf*t);%generates Rician[x,y]=demod(cr,fc,fs,'qam');

[xr,yr]=demod(crr,fc,fs,'qam');ae=(1/N)*sqrt(x.^2+y.^2);aer=(1/N)*sqrt(xr.^2+yr.^2);

pha=pi+angle(x+i*y);%phase to be centered around 2*pifigure

subplot(2,1,1)plot(t*1e3,cr),title('Rayleigh fading')xlabel('time ms')

ylabel('rf signal volt')xlim([0 .1])

aes=20*log10(ae);subplot(2,1,2)plot(t*1e3,aes),title('Rayleigh fading')

xlabel('time ms')ylabel('relative power dB')

xlim([0 .1])figuresubplot(2,1,1)

plot(t*1e3,crr),title('Rician fading')xlabel('time ms')

ylabel('rf signal volt')xlim([0 .1])

aerr=20*log10(aer);

subplot(2,1,2)plot(t*1e3,aerr),title('Rician fading')xlabel('time ms')

ylabel('relative power dB')xlim([0 .1])

fractra=0.0;for mf=1:nn;

Page 9: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 9/246

Page 9 of 246

if aes(mf)<=-10

fractra=fractra+1;else

end;end;

outageRayl=fractra/nnfractrc=0.0;for mf=1:nn;

if aerr(mf)<=-10fractrc=fractrc+1;

else

end;end;

outageRice=fractrc/nn

Problem 6.fadingsim.m

Page 10: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 10/246

Page 10 of 246

clear%fadingsim.m simulates fading including a carrier frequency and then demodulate

%uses random phase model as well as random delayfc=900e3;%carrier frequency

ppf=2*pi*fc;N=11;% Number of mutiple paths%a are considered to be Gamma distributed

fs=4*fc;%sampling rate

Ts=1/fs;

t = [0:Ts:1999*Ts]; %time arraynn=length(t);

ci=zeros(1,nn); %received signal (Rayleighnn=length(t);dist=1000;%distance between transmit and receive in meters

avdel=dist/3e8%average delay in secondsci=zeros(1,nn);

cir=zeros(1,nn);cit=0.0;%this uses a delay instead of Uniform phasefor m=1:N;

phterm=unifrnd(0,2*pi,1,nn);delay=avdel+(-0.5+unifrnd(0,2*pi,1,nn))*avdel;%uniform delay with a mean of avdel

a = gamrnd(1.4,1,1,nn);ci=ci+a.*cos(ppf*t+phterm);%Rayleigh%following term generates the received signal with delay format

cit=cit+a.*cos(ppf*t+delay);end;

crr=cit+2*cos(ppf*t);%rician[x,y]=demod(ci,fc,fs,'qam');[xt,yt]=demod(cit,fc,fs,'qam');

[xr,yr]=demod(crr,fc,fs,'qam');ae=(1/N)*sqrt(x.^2+y.^2);

aet=(1/N)*sqrt(xt.^2+yt.^2);aer=(1/N)*sqrt(xr.^2+yr.^2);

pha=pi+angle(x+i*y);%phase to be centered around 2*piphat=pi+angle(xt+i*yt);%phase of the delay version

figuresubplot(2,2,1)plot(t*1e3,ci),title('random phase: Rayleigh');

xlabel('time ms')ylabel('rf signal volt')

xlim([0 0.1])

subplot(2,2,2)

Page 11: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 11/246

Page 11 of 246

plot(t*1e3,ae),title('random phase:Rayleigh');

xlabel('time ms')ylabel('envelope volt')

xlim([0 0.1])

subplot(2,2,3)plot(t*1e3,cit),title('random delay:Rayleigh');xlabel('time ms')

ylabel('rf signal volt')xlim([0 0.1])

subplot(2,2,4)plot(t*1e3,aet),title('random delay:Rayleigh');

xlabel('time ms')ylabel('envelope volt')xlim([0 0.1])

figure

subplot(2,2,1)plot(t*1e3,crr),title('Rician')xlabel('time ms')

ylabel('rf signal volt')xlim([0 0.1])

subplot(2,2,2)plot(t*1e3,aer),title('Rician')

xlabel('time ms')ylabel('envelope volt')

xlim([0 0.1])

subplot(2,2,4)

hist(aer),title('envelope histogram-Rician fading')

subplot(2,2,3);hist(aet),title('envelope histogram-Rayleigh(delay)')

Page 12: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 12/246

Page 12 of 246

Problem 7.rayexp.m

clear

%rayexp.m%compares the Rayleigh and exponential

%verifies that if the envelope is Rayleigh, power is exponentially distributedx=raylrnd(1,1,1000);%1000 Rayleigh random numbers%%%It is also possible to generate Rayleigh random numbers directly from uniform random

numbers%%%%%%%%%%%

%xu=rand(1,1000);%1000 Uniform rand numbers

%x=1.0*sqrt(-log(xu));%%%%%%%%%%%%

xmean=mean(x);%meanxstd=std(x);%stdev

y=x.^2;%generates exponentially distributed setsubplot(2,1,1)hist(x),title('histogram of Rayleigh')

subplot(2,1,2)

Page 13: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 13/246

Page 13 of 246

hist(y),title('histogram of exponential');

ymean=mean(y)ystd=std(y)

ratio_Rayl=xmean/xstdratio_exp=ymean/ystdratio_Rayl=xmean/xstd

ratio_exp=ymean/ystd

ratio_Rayl = 1.8818ratio_exp = 0.9684

Problem 8.fadcom

outageRayl =

0.2945

Problem 9.fadcom

Page 14: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 14/246

Page 14 of 246

Problem 10.fadcom.m

outageRayl =

0.2945

outageRice =

0.2500

Problem 11. If the signal is Rayleigh faded, the power is exponentially distributed.

Therefore, the outage probability Pout is given by0

1 exp T

out

Z P

Z

= − −

where Z0 is the average power and ZT is the threshold power.

Z0 =10 dBm 10 mW

Page 15: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 15/246

Page 15 of 246

ZT=0 dBm 1 mW

Outage Probability =1

1 exp 0.27110

− − =

.

Problem 12

1

Prob SNR<0dB 1 exp2

= − − = 03935.

Problem 13. Threshold = 25-10=15 dB or 101.5.

Mean SNR = 25 dB or 102.5.1.5

2.5

101 exp 0.0952

10out P

= − − =

.

Problem 14. Threshold = 5 dB or 10.5.

.5

0

100.02 1 expout P

Z

= = − −

where Z0 is the average SNR.

( )

.5

0

10156.5 22

log .98e

Z dB= = →−

Problem 15. fadingsim.m

Page 16: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 16/246

Page 16 of 246

Problem 16.

.001 0 1 .1 3 1 4 .12.8926

.01 .1 1 .1sτ µ× + × + × + ×= =

+ + +.

2 22 2.001 0 1 .1 3 1 4 .1

8.84.01 .1 1 .1

sτ µ× + × + × + ×

= =+ + +

22. . 0.6898r m s d e l a y sτ τ µ= − =

Coherence BW =290 KHz.

Problem 17.

a.60 1 85 .1 110 .01

62.7.01 .1 1

nsτ× + × + ×

= =+ +

Page 17: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 17/246

Page 17 of 246

2 2 22 260 1 85 .1 110 .01

4000.01 .1 1

nsτ× + × + ×

= =+ +

22. . 8.48r m s d e l a y nsτ τ= − =

b.

0 .01 4 .1 8 17.57

.01 .1 1sτ µ

× + × + ×= =

+ +

2 2 22 20 .01 4 .1 8 1

59.1.01 .1 1

sτ µ× + × + ×

= =+ +

22. . 1.36r m s d e l a y sτ τ µ= − =

The response represented by (a) is an indoor channel response while the response represented by(b) is an outdoor channel one.

Problem 18. hatalog.m

clear% hatalog.m Power loss calculations

%incluse a plot of the lognormal fading suprimposed

close allPt=30;%power in dBm transmitted 1Wcarf=input('enter carrier freq. in MHZ...>>');lcrf=log10(carf);

ht=input('enter the height of BS antenna in meters..>>');%height in meters of the BSlht=log10(ht);

hr=input('enter the height of the MU antenna in meters..>>');%MU ant. height in meterslhr=log10(11.75*hr);N=60;%number of increments for distance

distmax=30;%coverage distance in Kmsfor kk=1:1:39;

d(kk)=1+0.5*(kk-1);fact1=69.55+26.16*lcrf-13.83*lht;fact2=(44.9-6.55*lht)*log10(d(kk));

fftq=fact1+fact2;%antenna correction factor MU...

ahr=3.2*(lhr)^2-4.97;% large cities; freq. above 400 MHzamr=(1.1*lcrf-0.7)*hr-(1.56*lcrf-0.8);alar(kk)=Pt-(fftq-ahr);

Page 18: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 18/246

Page 18 of 246

amed(kk)=Pt-(fftq-amr);

asub(kk)=Pt-(fftq-ahr-2*(log10(carf/28)).^2-5.4);arur(kk)=Pt-(fftq-ahr-4.78*(lcrf.^2)+18.33*lcrf-40.94);

xlar(kk)=alar(kk)+normrnd(0,10);%10 dB std deviation for big city with mean equal to thereceived power

xmed(kk)=amed(kk)+normrnd(0,8);%8 dB std deviation for med cityxsub(kk)=asub(kk)+normrnd(0,4);%4 dB std deviationxrur(kk)=arur(kk)+normrnd(0,3);%3 dB std deviation

end;

subplot(2,2,1)

plot(d,alar,d,xlar);xlabel('distance Km');xlim([2 20])

ylabel('Received Power dBm');title('large city');

subplot(2,2,2)

plot(d,amed,d,xmed);

%axis([1 30 -140 -60]);xlabel('distance Km');

xlim([2 20])

ylabel('Received Power dBm');title('medium city');

subplot(2,2,3)

plot(d,asub,d,xsub);

%axis([1 30 -140 -60]);xlabel('distance Km');

xlim([2 20])

ylabel('Received Power dBm');title('suburban');

subplot(2,2,4)

plot(d,arur,d,xrur);

%axis([1 30 -140 -60]);xlabel('distance Km');

xlim([2 20])

Page 19: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 19/246

Page 19 of 246

ylabel('Received Power dBm');

title('rural');

Problem 19. rice.m

clear;close all

%rice.m%generates a Rician distributionfor kr=1:10

rpara=input('mean of the Gaussian to create Rician...>');rp2=rpara^2;

n=1000;%number of samples

x=normrnd(0,1,1,1000);xx=normrnd(rpara,1,1,1000);

ac=x.^2+xx.^2;r=sqrt(ac);%rician variable

ax=0.:0.2:20;% range of values for the histogram

figure

Page 20: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 20/246

Page 20 of 246

yy=hist(r,ax);

%hist(r,ax),title('histogram of Rician Distribution');ax1=rp2+ax.^2;

bes1=besseli(0,ax*rpara);y=ax.*bes1.*exp(-ax1/2);

plot(ax,yy/max(yy),'+',ax,y/max(y))legend('histogram','pdf')xf=input('enter 1 for another mean and 0 to stop..>>');

if xf==0break

else

end;end;

Page 21: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 21/246

Page 21 of 246

You can verify that the numbers are Rician distributed by conducting a chi-square test using thefollowing MATALB program.

function [q]=chirice(x,mm);%data, and bins

%does the chi-square testing of the data to see Ricain is a fit.xx=sort(x);%using the moments of the data estimate the two parameters

a4=mean(xx.^4);my=mean(xx.^2);

a = (2*my*my-a4)^0.25; %Rician parameterb=sqrt(0.5*(my-a^2));

inter = max(xx) - min(xx); %interval for chi-square testintstep = inter/mm; %size of sub-interval

intval = [min(xx):intstep:max(xx)]; %samples at the sub-intervalsk = [zeros(1,mm)]; %number of samples in each sub-interval

%counting the samples in each sub-intervalfor i = 1:length(xx)

for j = 1:mm

Page 22: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 22/246

Page 22 of 246

if xx(i) <= intval(j+1)

k(j) = k(j) + 1;break;

end;end;

end;Fy=1-marcumq(a/b,intval/b);%CDF uses marcumq function from Communications Toolboxp = zeros(1,mm);

for i = 1:mmp(i) = Fy(i+1) - Fy(i); %probabilities at the sub-interval samples

end;

np = p.*length(xx);

q = 0;for i = 1:mm

q = q + ((k(i)-np(i))^2)/np(i); %chi-square testend;

Problem 20 . ricetoNakagami.m

The Nakagami pdf is given by ( )( ) ( ) ( )

2 1 22 expm m

m

m x m

m f x x U x

ΩΓ Ω= − . When m=1, this equation

becomes ( ) ( ) ( )2 2

2

exp x x

f x U xΩ Ω= − , the Rayleigh density function. Rician becomes Rayleighwhen the Rician parameter K(dB) →−∞ .

clear

%ricetoNakagami.m%generates a Rician distribution, estimates the Nakagami parameter to show that

%m>1 for Ricianfor kk=1:21rr(kk)=(kk-1)*0.2;%A0 value of the Rician

r0=rr(kk);

x=randn(1,1000);%1000 Gaussian random numbersxx=randn(1,1000);%1000 Gaussian random numbers

x1=xx+r0;%Gaussian with different means

a=sqrt(x1.^2+x.^2);%calculate the envelope

hist(a),title('histogram of Rician Distribution');r2=mean(a.^2);

Page 23: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 23/246

Page 23 of 246

r4=mean(a.^4);

m(kk)=r2^2/(r4-r2^2);end;

figure

RRdB=10*log10(rr.^2/2);plot(RRdB,m,'+')xlabel('Ricean parameter dB')

ylabel('Nakagami parameter m')

Problem 21. ricetoNakagami.m

Eqn. (2.59) is ( ) ( ) ( )2 2

0 02 2 202

expa A aA A

A f a I σ σ σ

+= − .

2 2 2

02 E A Aσ = + …….Rician

2 E A = Ω ……..Nakagami

Thus, 2 2

02 AσΩ = + . Also, using the expression for m (eqn. 2.72), we can write

Page 24: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 24/246

Page 24 of 246

( )

22

0

24 4

0 0

2 2222 2

00

2

211 1 1

21

2

A

A A

m A A

σ

σ

σ

= − = − = −

Ω ++

.

Note that ( ) ( )20

210 210log

AK dB

σ= . It is now possible to relate K(dB) to the Nakagami parameter

m. (Shown above).

Problem 22. Doppler shift6

8

900 10 8000066.6

3 10 60 60d

v f f Hz

c

× ×= = =

× × ×2

.36

1

2

1

2 .6 66.67d

eav f

π ατ

π− −

= =×

=.0043 s

2 .362 2 66.67 .6 e 70 A d N f e απ α π− −= = × × = .

Problem 23. Coherence BW = 10 KHz

Data rate = 5 kbps

Data rate < coherence bandwidth→ Channel is flat.

Coherence Time = 100 sµ

Pulse duration =1

2005000

sµ=

Pulse duration > coherence time → fast fading.

Problem 24. freqselresponse.m

The relative attenuation of the frequency components varies with the strength of the two waves.This will change the coherence bandwidth of the channel.

Page 25: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 25/246

Page 25 of 246

Figure Ex. 2-24

Problem 25.Gaussexp and chiexp

clear

close all%Gaussexp.m%generates exponential from two Gaussian random numbers

%histogram is compared to the exponential pdf x1=normrnd(0,.5,1,10000);%10000 Gaussian random numbers

x2=normrnd(0,.5,1,10000);%10000 Gaussian random numbers

y=x1.^2+x2.^2;x=min(y):max(y)/80:max(y);

hist(y,x);xh=hist(y,x);

hold on%plot(x,xh/max(xh))

ymean=mean(y);

Page 26: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 26/246

Page 26 of 246

ystd=std(y);

ratio=ymean/ystd

exf=exppdf(x,ymean);%generates exponential pdf having the same meanhold on

exf=exf*max(xh)/max(exf);plot(x,exf,'r')legend('expoential pdf')

xlabel('x')ylabel('pdf or histogram')

Problem 26.pulsedisp.m

%pulsedisp.m

%shows the effect of frequency selective effects by adding ten different pulses%shifted and weighted%Gaussian pulses used

close allclearfor kp=1:3;

%plots three separate generation to show the effect of random paths and random weights%w=rand(10,1);%weights for 10 pulses

Page 27: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 27/246

Page 27 of 246

%tt=100*rand(10,1);%delay is also considered to be random

NN=1024;sigma2=200;%sigmasquare

p0=500;%for p=1:NN;

xx=zeros(1,NN);p=1:NN;t(p)=p;

p1=p-p0;for kn=1:10;xx=xx+(1/sqrt(2*pi*sigma2))*rand(1)*exp(-(p1-100*rand(1)).^2/(2*sigma2));%10 pulses

addedend;

x1=(1/sqrt(2*pi*sigma2))*rand(1)*exp(-(p1-100*rand(1)).^2/(2*sigma2));%a single pulsexxx=xx/max(xx);x1=x1/max(x1);

subplot(2,2,kp+1)plot(t,xxx);

xlim([400 800])%finds the mean and standard deviation of the Gaussian pulsexpp=sum(xxx);%denominator

xp=sum(t.*xxx)/xpp;%mean......sum(pi.xi)/sum(pi)t2=t.^2;

xp2=sum(t2.*xxx)/xpp;%second momentstdval=sqrt((xp2-xp^2))%standard deviation

end;

subplot(2,2,1)plot(t,x1),title('Transmitted Pulse')

xlim([400 800])sum2=sum(x1);xy1=sum(t.*x1)/sum2;

xy2=sum(t2.*x1)/sum2;stval=sqrt(xy2-xy1^2)%standard deviation ...single pulse

Page 28: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 28/246

Page 28 of 246

r.m.s width (transmitted) = 14.1421r.m.s width (received) = 25.2188, 24.2574, 24.1377

Problem 27 (a) ricetoGaussian.m

clear;close all

%ricetoGaussian.m ;generates a Rician distribution%compares the histogram to Rician pdf and to a Gaussian pdf having identical%mean and variance

st=2;%standared deviation of Gaussian neededst2=st^2;

for kr=1:10

rpara=input('mean of the Gaussian to create Rician...>');rp2=rpara^2;

%use 5000 random variablesx=normrnd(0,st,1,5000);

xx=normrnd(0,st,1,5000);%another gaussian random variablex1=xx+rpara;%Gaussian with different meansx2=x.^2;

xx2=x1.^2;

Page 29: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 29/246

Page 29 of 246

xy=x2+xx2;

sst=2*st2;KdB=10*log10(rp2/sst);

kkdb=num2str(KdB);titlefigure=strcat('KdB=',kkdb)

r=sqrt(xy);%Rician random variable

meanp=mean(r)

varp=var(r);%variance

ax=0.:0.2:20;% range of values for the histogram

figureyy=hist(r,ax);

%hist(r,ax),title('histogram of Rician Distribution');ax1=rp2+ax.^2;bes1=besseli(0,ax*rpara/st2);

y=(1/st2)*ax.*bes1.*exp(-ax1/(2*st2));yg=sqrt(1/(2*pi*varp))*exp(-(ax-meanp).^2/(2*varp));%Gaussian pdf

plot(ax,yy/max(yy),'+',ax,y/max(y),ax,yg/max(yg),'*'),title(titlefigure)xlabel('envelope')ylabel('pdf or histogram')

legend('hostogram','envelope pdf','Gaussian approx.')xf=input('enter 1 for another mean and 0 to stop..>>');

if xf==0break

else

end;end;

Page 30: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 30/246

Page 30 of 246

Another way to explore this relationship is to see if the ratio of the median to mean is equal tounity. This happens when Rician becomes Gaussian.

Page 31: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 31/246

Page 31 of 246

Problem 28. nakagenerice.m

clear%nakagenerice.m

%generates Nakagami distributed random numbers and estimates the parameters%conduct the Chi-square testing for Rayleigh and Nakagami and Rice

mval=input('enter the value of m......>');om=input('enter the value of omega....>');

N=input('the number of random numbers to be generated...>');y=gamrnd(mval,om/mval,1,N);%Generates Gamma distributed random variables

x=sqrt(y);%generates Nakagami dsitributed random variable which is the square root of theGamma variablemy=mean(x.^2)%gives the value of omega

omega=myav4=mean((x.^2-my).^2);mn=my*my/av4%m-value directly

mm=20;%number of binsxx=sort(x); % random samples

Page 32: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 32/246

Page 32 of 246

inter=max(x)-min(x); %interval for chi-square test

intstep=inter/mm; %size of sub-intervalintval=[min(x):intstep:max(x)]; %samples at the sub-intervals

k=[zeros(1,mm)]; %number of samples in each sub-interval intializationfor i=1:N

for j=1:mmif xx(i)<=intval(j+1)k(j)=k(j)+1;

break;end;

end;

end;p=zeros(1,mm);

for i=1:mmyin=intval(i+1)*intval(i+1);zin=intval(i)*intval(i);

p(i)=gamcdf(yin*mn,mn,my)-gamcdf(zin*mn,mn,my); %probabilities at the sub-intervalsamples

end;np=p.*N;q=0;

for i=1:mmq = q + ((k(i)-np(i))^2)/np(i); %chi-square test

end;chisquare_Nakagami=q%chisquare valueq_Rayl=chirayleigh(x,mm)

if mval<=1%do not conduct the Rice test

break end;%%%% testing for Rice

%%from the paper by Nakagami

%using the moments of the dataa4=mean(xx.^4);a = (2*my*my-a4)^0.25; %Rician parameter

b=sqrt(0.5*(my-a^2));

inter = max(xx) - min(xx); %interval for chi-square testintstep = inter/mm; %size of sub-intervalintval = [min(xx):intstep:max(xx)]; %samples at the sub-intervals

k = [zeros(1,mm)]; %number of samples in each sub-interval

%counting the samples in each sub-intervalfor i = 1:length(xx)

for j = 1:mm

Page 33: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 33/246

Page 33 of 246

if xx(i) <= intval(j+1)

k(j) = k(j) + 1;break;

end;end;

end;

Fy=1-marcumq(a/b,intval/b);%CDF uses marcumq function from Communications Toolbox

p = zeros(1,mm);for i = 1:mm

p(i) = Fy(i+1) - Fy(i); %probabilities at the sub-interval samples

end;np = p.*length(xx);

q = 0;for i = 1:mm

q = q + ((k(i)-np(i))^2)/np(i); %chi-square test

end;q_Rice=q

**The above program needs the following segment: chirayleigh

function [q]=chirayleigh(yy,m)

%Tests for Rayleigh distribution%[chu)]=chirayleigh(samp,bins)

y=sort(yy); % random samplesN=length(yy);

my=mean(yy);%meaninter=max(y)-min(y); %interval for chi-square testintstep=inter/m; %size of sub-interval

intval=[min(y):intstep:max(y)]; %samples at the sub-intervalsk=[zeros(1,m)]; %number of samples in each sub-interval intialization

for i=1:Nfor j=1:m

if y(i)<=intval(j+1)k(j)=k(j)+1;break;

end;end;

end;

myp=my*sqrt(2/pi);%Rayleigh parameter

p=zeros(1,m);for i=1:m

p(i)=raylcdf(intval(i+1),myp)-raylcdf(intval(i),myp); %probabilities at the sub-interval samples

Page 34: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 34/246

Page 34 of 246

end;

np=p.*N;

q=0;

for i=1:mq = q + ((k(i)-np(i))^2)/np(i); %chi-square testend;

*****

Problem 29. outlognorm.m

%outlognorm.m

%computes the outage probability for a given average power and a fixed threshold% as a function of the standard deviation of lognormal fading

%also generates the outage from a set of random numbers

clearclose all

%outage probability calculation for lognormalN=2000;%number of random numbers to be generated

pdb=input('enter the average power in dBm....>>>>');pthr=input('threshold power in dBm... less than the average power >')st=[1:1:15];%standard deviation of fading

sq=sqrt(2)*st;sqt=1./sq;ff=(pdb-pthr)*sqt;

pout=0.5*erfc(ff);

for k=1:15;x=normrnd(pdb,k,1,N);count=0;

for kk=1:N;if x(kk)<=pthr

count=count+1;elseend;

end;pouts(k)=count/N;% outage from simulation..random numbers

end;

plot(st,pout,'g',st,pouts,'r')legend('Theoretical Outage','Simulated Outage')

xlabel('standard deviation of fading dB')ylabel('outage probability')

Page 35: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 35/246

Page 35 of 246

enter the average power in dBm....>>>>-95

threshold power in dBm... less than the average power >-100

Problem 30. 0.52

av t out

P PP erfcσ

− =

2 12

av t out

P PP erf

σ

− = −

( )2.65

1 22

av t

out

P PdB

erfinv Pσ

−= =

Problem 31. Gausschiexp.m

clear

close all%Gausschiexp.m%generates exponential from two Gaussian random numbers

%conducts a chi-square test to validate exponential pdf x1=normrnd(0,.5,1,10000);%10000 Gaussian random numbers

x2=normrnd(0,.5,1,10000);%10000 Gaussian random numbersyy=x1.^2+x2.^2;m=20;%number of bins

Page 36: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 36/246

Page 36 of 246

y=sort(yy); % random samples

N=length(yy);%size of the samplemy=mean(y);%mean and exponential parameter

inter=max(y)-min(y); %interval for chi-square testintstep=inter/m; %size of sub-interval

intval=[min(y):intstep:max(y)]; %samples at the sub-intervalsk=[zeros(1,m)]; %number of samples in each sub-interval intialization

for i=1:Nfor j=1:m

if y(i)<=intval(j+1)

k(j)=k(j)+1;break;

end;end;

end;

p=zeros(1,m);for i=1:m

p(i)=expcdf(intval(i+1),my)-expcdf(intval(i),my); %probabilities at the sub-interval samples

end;

np=p.*N;

q=0;

for i=1:mq = q + ((k(i)-np(i))^2)/np(i); %chi-square test

end;

chi_squaretest_val=q

Problem 32. unitoGaussian.m

Chi-square values

21.571324.3384

19.330519.3305

%unitoGaussian.m%test to see whether the sum of uniform random variables tend towards Gaussian

%conducts chi-square testsclearclose all

Page 37: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 37/246

Page 37 of 246

N=1000

x1=rand(1,N);x2=rand(1,N);

x3=rand(1,N);x4=rand(1,N);;

x5=rand(1,N);x6=rand(1,N);xx2=x1+x2+x3;

xx3=xx2+x4;xx4=xx3+x5;xx5=xx4+x6;

m=20;%number of binssubplot(2,2,1)

hist(xx2), title('sum of three random variables')chigauss(xx2,m)%chi-square valuesubplot(2,2,2)

hist(xx3),title('sum of four random variables')chigauss(xx3,m)%chi-square value

subplot(2,2,3)hist(xx4),title('sum of five random variables')chigauss(xx4,m)%chi-square value

subplot(2,2,4)hist(xx5),title('sum of six random variables')

chigauss(xx4,m)%chi-square value

also requires the following program……

function [q]=chigauss(yy,m)%Tests for Normal distribution%[chu)]=chigauss(samp,bins)

y=sort(yy); % sort samplesN=length(yy);mean=mean(y);

stdev=std(y);inter=max(y)-min(y); %interval for chi-square test

intstep=inter/m; %size of sub-intervalintval=[min(y):intstep:max(y)]; %samples at the sub-intervalsk=[zeros(1,m)]; %number of samples in each sub-interval intialization

for i=1:N

for j=1:mif y(i)<=intval(j+1)

k(j)=k(j)+1;

break;end;

end;

Page 38: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 38/246

Page 38 of 246

end;

p=zeros(1,m);

for i=1:mp(i)=normcdf(intval(i+1),mean,stdev)-normcdf(intval(i),mean,stdev); %probabilities at thesub-interval samples

end;

np=p.*N;

q=0;

for i=1:mq = q + ((k(i)-np(i))^2)/np(i); %chi-square test

end;

Problem 33. The results show that as the number of random variables increase, the sum of

the random variables approach Gaussian. The Rayleigh fading is a result of multiple paths and

when the number of multiple paths increase, the density function of the sum of the phasors

Page 39: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 39/246

Page 39 of 246

giving rise to the amplitude (inphase and quadrature components) approach Gaussian and the pdf

envelope approaches Rayleigh.

Problem 34.rayoutage1

clear%rayoutage1close all

%generates Rayleigh faded signal with 10 multiple paths%compares the outage to theoretical outage

numpaths = 10; %number of pathsFc = 900e6; %carrier frequencyFs = 4*Fc; %sampling frequency

Ts = 1/Fs; %sampling periodt = [0:Ts:1999*Ts]; %time array

wc = 2*pi*Fc; %radian frequency

ray = zeros(1,length(t)); %received signalfor i = 1:numpaths

a = weibrnd(1,3,1,length(t)); %scattering strengts are Weibull distributedray = ray + a.*cos(wc*t+unifrnd(0,2*pi,1,length(t)));

end;[rayi rayq] = demod(ray,Fc,Fs,'qam'); %demodulated signalenv_ray = sqrt(rayi.^2+rayq.^2); %envelope of received signal

%computation of the outage probabilitiespower_ray=env_ray.^2;powerdB=10*log10(power_ray);

mean_power=10*log10(mean(env_ray.^2))

MK=length(env_ray)for k=1:20;

pow(k)=mean_power-2*k; %threshold powerkps=pow(k);

ratio=10^(kps/10)/10^(mean_power/10);poutth(k)=1-exp(-ratio);%theoretical outage

count=0;for ku=1:MK;

power=powerdB(ku);%power in dB

if power <= kpscount=count+1;

elseend;

end;

poutsim(k)=count/MK;%outage probability simulatedend;

figureplot(pow,poutth,':',pow,poutsim,'--'),title('Outage ---Rayleigh')xlabel('threshold power dBm')

Page 40: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 40/246

Page 40 of 246

ylabel('outage probability')

legend('pout_th','pout_sim')

Problem 35. riceout1.m

clear%riceout1.m

%generates a fading signal where a direct (LOS) component is present%generates the RF signal and calculate the outage

close allnumpaths = 10; %number of paths

Fc = 900e6; %carrier frequencyFs = 4*Fc; %sampling frequencyTs = 1/Fs; %sampling period

t = [0:Ts:1999*Ts]; %time arraywc = 2*pi*Fc; %radian frequencyrice = zeros(1,length(t)); %received signal

for i = 1:numpaths-1a = weibrnd(1,3,1,length(t)); %scattering strengtsh are Weibull distributed

Page 41: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 41/246

Page 41 of 246

rice = rice + a.*cos(wc*t+unifrnd(0,2*pi,1,length(t)));

end;rice = rice + 4.5*cos(wc*t);%adds the direct path

[ricei riceq] = demod(rice,Fc,Fs,'qam'); %demodulated signalenv_rice = sqrt(ricei.^2+riceq.^2); %envelope of received signal

b = sqrt((std(ricei)^2 + std(riceq)^2)/2); %Rician parametera = mean(ricei); %Rician parameterpower_rice=env_rice.^2;

powerdB=10*log10(power_rice);mean_power=10*log10(mean(env_rice.^2))MK=length(env_rice)

for k=1:20;pow(k)=mean_power-2*k; %threshold power

kps=pow(k);count=0;for ku=1:MK;

power=powerdB(ku);%power in dBif power <= kps

count=count+1;elseend;

end;poutsim(k)=count/MK;%outage probability simulated

kbs=10^(kps/10);%power in mWpoutth(k)=1-marcumq(a/b,sqrt(kbs)/b);%from the communications toolbox

end;

figureplot(pow,poutsim,pow,poutth),title('Outage ---Rician')

xlabel('thrshold power dBm')ylabel('outage probability')legend('poutth','poutsim')

Page 42: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 42/246

Page 42 of 246

Problem 36.lognormf.m

clearclose all

%exploration of the generation of lognormal%lognormf.m

%generates a set of lognormal random numbers based on the principle that the procuct of a set of random%numbers will give rise to lognormal

mm=input('number of components for the product operation to check for lognormal..');for k=1:1000;

x(k)=prod(raylrnd(1,1,mm));%generates the product of mm Rayleigh random numbersend;

subplot(2,1,1)hist(x),title('histogram of the product of Rayleigh numbers')xlabel('volt')

yy=10*log10(x.^2);subplot(2,1,2)hist(yy),title('histogram after conversion..10log_10x^2..')

xlabel('dBm')

Page 43: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 43/246

Page 43 of 246

%Tests for Normal distributionm=20;%number of bins for the chi-square test

y=sort(yy); % sort samplesN=length(y);

mean=mean(y);stdev=std(y);inter=max(y)-min(y); %interval for chi-square test

intstep=inter/m; %size of sub-intervalintval=[min(y):intstep:max(y)]; %samples at the sub-intervalsk=[zeros(1,m)]; %number of samples in each sub-interval intialization

for i=1:N

for j=1:mif y(i)<=intval(j+1)

k(j)=k(j)+1;

break;end;

end;end;

p=zeros(1,m);for i=1:m

p(i)=normcdf(intval(i+1),mean,stdev)-normcdf(intval(i),mean,stdev); %probabilities at thesub-interval samplesend;

np=p.*N;

q=0;for i=1:m

q = q + ((k(i)-np(i))^2)/np(i); %chi-square testend;

chi_square_val=q

Page 44: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 44/246

Page 44 of 246

Problem 37. fadlogfm.m

%fadlogfm.m%explores the generation of lognormal fading. There is multiple scattering. There are also

multiple paths.%This will lead to Rayleigh envelope where the mean of the envelope will be random

clearclose all%simulates lognormal fading

fc=1e5;%carrier frequencyppf=2*pi*fc;

N=11;% Number of mutiple paths%a are considered to be Gamma distributed

fs=4*fc;%sampling rateTs=1/fs;t = [0:Ts:1999*Ts]; %time array

nn=length(t);

for kr=1:1000;%1000 rf waveforms are genaretd to see the statistics of the mean and the meadian

powers%multiple reflections

Page 45: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 45/246

Page 45 of 246

%

%ggm is the result of multiple scattering; thus each multipath is produced by multiple(20)scattering.

%the statistics of the mean and median of the Rayleigh have been computed.%NOTE THAT THE MULTIPLE REFLECTIONS OCCUR FIRST AND THEN THIS

MULTIPLY REFLECTED COMPONENTS%GET REFLECTED/SCATTERED/DIFFRACTED TO TAKE MULTIPLE PATHS TOTHE RECEIVER.

%THE MULTIPLE SCATTERING COMPONENTS IDENTIFIED BY EACH OF THEggm

%WILL BE RAYLEIGH DUE TO THE PRESENCE OF MUTIPLE SCATTERERS IN

THE REGION%IN WHICH THE THE SCATTERING TAKES PLACE.

ggm=prod(raylrnd(1.5,1,20));%generates the product of 20 Rayleigh r.vcr=zeros(1,nn);

for m=1:N;

phterm=2*pi*unifrnd(0,2*pi,1,nn);cr=cr+ggm*cos(ppf*t+phterm);%Rayleigh

end;[x,y]=demod(cr,fc,fs,'qam');ae=(1/N)*sqrt(x.^2+y.^2);%ae will be Rayleigh

ae=ae;mm(kr)=mean(ae);

med(kr)=median(ae);end;mm2=mm.^2;

med2=med.^2;mmdB=10*log10(mm2);%mean power in dBm

meddB=10*log10(med2);%median power in dBm

%%% note that both average ( or median) of envelope and average of the power will be

lognormal

plot(t*1e3,cr/max(abs(cr))),title('rf signal incorporating lognormal fading');xlabel('time ms')

ylabel('rf signal volt')xlim([0 0.5])

figuresubplot(2,2,1)

hist(mm),title('histogram of the mean power')xlabel('volt')

subplot(2,2,2)hist(med),title('histogram of the median power')xlabel('volt')

Page 46: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 46/246

Page 46 of 246

subplot(2,2,3)

hist(mmdB),title('histogram of the mean power (dBm)')xlabel('dBm')

subplot(2,2,4)hist(meddB),title('histogram of the median power (dBm)')

xlabel('dBm')

Problem 38. fadlogfm.m (See the previous problem # 37)

Page 47: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 47/246

Page 47 of 246

Problem 39.lognormf.m

clearclose all

%exploration of the generation of lognormal%lognormf.m

%generates a set of lognormal random numbers based on the principle that the procuct of a set of random%numbers will give rise to lognormal

mm=input('number of components for the product operation to check for lognormal..');for k=1:1000;

x(k)=prod(raylrnd(1,1,mm));%generates the product of mm Rayleigh random numbersend;

subplot(2,1,1)hist(x),title('histogram of the product of Rayleigh numbers')xlabel('volt')

yy=10*log10(x.^2);subplot(2,1,2)hist(yy),title('histogram after conversion..10log_10x^2..')

xlabel('dBm')

Page 48: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 48/246

Page 48 of 246

%Tests for Normal distributionm=20;%number of bins for the chi-square test

y=sort(yy); % sort samplesN=length(y);

mean=mean(y);stdev=std(y);inter=max(y)-min(y); %interval for chi-square test

intstep=inter/m; %size of sub-intervalintval=[min(y):intstep:max(y)]; %samples at the sub-intervalsk=[zeros(1,m)]; %number of samples in each sub-interval intialization

for i=1:N

for j=1:mif y(i)<=intval(j+1)

k(j)=k(j)+1;

break;end;

end;end;

Problem 40. lognormfchi.m

clearclose all

%exploration of the generation of lognormal

%lognormfchi.m%generates a set of lognormal random numbers based on the principle that the procuct of a set of random%numbers will give rise to lognormal

%chi-square tests directly and indirectly using Gaussianmm=input('number of components for the product operation to check for lognormal..');

for k=1:1000;x(k)=prod(raylrnd(1,1,mm));%generates the product of mm Rayleigh random numbers

end;

subplot(2,1,1)hist(x),title('histogram of the product of Rayleigh numbers')

xlabel('volt')yy=10*log10(x.^2);subplot(2,1,2)

hist(yy),title('histogram after conversion..10log_10x^2..')xlabel('dBm')

%%% testing directly for lognormalm=20;

Page 49: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 49/246

Page 49 of 246

N=length(x);

%Tests for lognormal distribution%[chu)]=chilogn(samp,bins)

y=sort(x); % random samplesms=std(log(y));%sigma of the lognormal *** not the standard deviation

inter=max(y)-min(y); %interval for chi-square testintstep=inter/m; %size of sub-intervalintval=[min(y):intstep:max(y)]; %samples at the sub-intervals

k=[zeros(1,m)]; %number of samples in each sub-interval intialization

for i=1:N

for j=1:mif y(i)<=intval(j+1)

k(j)=k(j)+1;break;

end;

end;end;

my=mean(log(y));%parameter mu of the lognormal pdf*** not the mean of lognormalp=zeros(1,m);for i=1:m

p(i)=logncdf(intval(i+1),my,ms)-logncdf(intval(i),my,ms); %probabilities at the sub-intervalsamples

end;

np=p.*N;

q=0;

for i=1:mq = q + ((k(i)-np(i))^2)/np(i); %chi-square test

end;

ch_lognorm_val=q

clear qclear y%Tests for Normal distribution

m=20;%number of bins for the chi-square testy=sort(yy); % sort samples

N=length(y);mean=mean(y);stdev=std(y);

inter=max(y)-min(y); %interval for chi-square testintstep=inter/m; %size of sub-interval

intval=[min(y):intstep:max(y)]; %samples at the sub-intervalsk=[zeros(1,m)]; %number of samples in each sub-interval intialization

Page 50: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 50/246

Page 50 of 246

for i=1:N

for j=1:mif y(i)<=intval(j+1)

k(j)=k(j)+1;break;

end;end;end;

p=zeros(1,m);for i=1:m

p(i)=normcdf(intval(i+1),mean,stdev)-normcdf(intval(i),mean,stdev); %probabilities at thesub-interval samplesend;

np=p.*N;

q=0;for i=1:m

q = q + ((k(i)-np(i))^2)/np(i); %chi-square testend;

chi_square_val=q

Problem 41.hatawalf.m

clearclose all% hatawalf.m Power loss calculations%using Hata model and Walfisch

carf=880;%carrier frequency of in MHzlcrf=log10(carf);

ht=30;%height in meters of the BSlht=log10(ht);hr=1.5;%MU ant. height in meters

lhr=log10(11.75*hr);N=60;%number of increments for distance

distmax=30;%coverage distance in Kmsfor kk=1:30;d(kk)=1+0.5*(kk-1);

fact1=69.55+26.16*lcrf-13.83*lht;fact2=(44.9-6.55*lht)*log10(d(kk));

fftq=fact1+fact2;%antenna correction factor MU...ahr=3.2*(lhr)^2-4.97;% large cities; freq. above 400 MHz

Page 51: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 51/246

Page 51 of 246

amr=(1.1*lcrf-0.7)*hr-(1.56*lcrf-0.8);

alar(kk)=fftq-ahr;%Hata model

lfree=32.4+20*log10(d(kk))+20*lcrf;%free space losssw=15;%street width

hb=30;%building height=antenna height=separation of buildingsdhb=0;%no difference in heights of bdg and antennadhm=hb-hr;

ang=90;%angle philrts=-16.9+10*lcrf-10*log10(sw)+20*log10(dhm)+4-.114*90;lms=0+54+18*log10(d(kk))+(-4+1.5*(carf/925-1))*lcrf-9*log10(hb);

alf(kk)=lfree+lrts+lms;%W-I modelend;

plot(d,alar,d,alf);legend('Hata model','Walfish-Ikegami model')

%axis([1 30 -140 -60]);xlabel('distance Km');ylabel('power loss dB');

%for transfering to excel directly as columnsd=d';

alf=alf';alar=alar';

Page 52: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 52/246

Page 52 of 246

Problem 42. See the textbook; relevant sections

Problem 43. See the textbook; relevant sections

Problem 44. coheBW.m

%coheBW.m%plot of the correlation of faded channelsclear

close all

for k=1:50;x(k)=0.05*(k-1);x1=x(k);sigma=1;

y(k)=1/(1+(2*pi*x1*sigma)^2);%corr coef. freqy1=besselj(0,2*pi*x1);

yy(k)=y1^2;%corr. Coeff timeend;

Page 53: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 53/246

Page 53 of 246

subplot(2,1,1)plot(x,y), title('frequency correlation')

xlabel('\Delta f')ylabel('\rho (\Delta f,0)')

subplot(2,1,2);plot(x,yy),title('temporal correlation')xlabel('\Delta t')

ylabel('\rho (0,\Delta t)')

The delay

δcan be described using the exponential pdf,

( ) ( )

1exp f U

δδ δ

δ δ

= −

where δ is the average delay. Making use of the properties of the exponential density function,

we have [ ] ; 0.5 E msδ

δ δ σ δ= = = . Thus, the maximum data rate will be approximately equal

to1

2000bpsδ

= .

Page 54: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 54/246

Page 54 of 246

Problem 45.fadcomRayl. m and chirayleigh.m (see next problem)

clear%fadcomRayl.m simulates multiptah fading varying the number of paths

%Compares the histogram to a Rayleigh pdf close allfc=900e3;%carrier frequency

ppf=2*pi*fc;N1=[3 5 7 10]

%a are considered to be Gamma distributedfs=4*fc;%sampling ratedt=1/fs;

nn=1e-3/dt;%total number of samples in one m secM=2^(nextpow2(nn))

dist=1000;%distance between transmit and receive in meters

avdel=dist/3e8;%average delay in secondsfor kmm=1:4

N=N1(kmm)for k=1:nn;

t(k)=k*dt;ci=0.0;cir=0.0;

for m=1:N;phterm=2*pi*rand(1);

ci=ci+gamrnd(1.4,1)*cos(ppf*t(k)+phterm);%Rayleigh including Doppler

end;

cr(k)=ci;end;[x,y]=demod(cr,fc,fs,'qam');ae=(1/N)*sqrt(x.^2+y.^2);

pha=pi+angle(x+i*y);%phase to be centered around 2*pinumb=num2str(N);

fx=strcat('Multipath fading....','N=',numb);figure

subplot(2,2,1)

plot(t*1e3,cr),title(fx)xlabel('time ms')

ylabel('rf signal volt')xlim([0 .1])aes=20*log10(ae);

subplot(2,2,2)plot(t*1e3,aes),title(fx)

xlabel('time ms')ylabel('relative power dB')xlim([0 .1])

Page 55: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 55/246

Page 55 of 246

subplot(2,2,3)

ax=0.:0.1:5;% range of values for the histogramyy=hist(ae,ax);

bb=mean(ae)*sqrt(2/pi);%Rayleigh parameter by=raylpdf(ax,bb);%Rayl density function of parameter b

plot(ax,yy/max(yy),'+',ax,y/max(y)),title(fx)legend('histogram','Rayleigh pdf')xlabel('envelope')

qq=chirayleigh(ae,20)%chi-square valueend;

Page 56: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 56/246

Page 56 of 246

Page 57: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 57/246

Page 57 of 246

Page 58: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 58/246

Page 58 of 246

Page 59: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 59/246

Page 59 of 246

Page 60: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 60/246

Page 60 of 246

Problem 46.fadconRayl (see previous problem) and chirayleigh

function [q]=chirayleigh(yy,m)%Tests for Rayleigh distribution

%[chu)]=chirayleigh(samp,bins)y=sort(yy); % random samplesN=length(yy);

my=mean(yy);%meaninter=max(y)-min(y); %interval for chi-square test

intstep=inter/m; %size of sub-intervalintval=[min(y):intstep:max(y)]; %samples at the sub-intervals

k=[zeros(1,m)]; %number of samples in each sub-interval intialization

for i=1:N

for j=1:mif y(i)<=intval(j+1)

k(j)=k(j)+1;

break;end;

Page 61: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 61/246

Page 61 of 246

end;

end;

myp=my*sqrt(2/pi);%Rayleigh parameterp=zeros(1,m);

for i=1:mp(i)=raylcdf(intval(i+1),myp)-raylcdf(intval(i),myp); %probabilities at the sub-interval samplesend;

np=p.*N;

q=0;for i=1:m

q = q + ((k(i)-np(i))^2)/np(i); %chi-square testend;

N = 3; Chi-square value = 4.7997e+003

N = 5; Chi-square value = 380.6133

N = 7; Chi-square value = 284.7777

N = 10; Chi-square value = 29.6699

Problem 47 .pulsefading.m

clear%pulsefading.m fading including a carrier frequency

%three delays are created; Pulse stream is delayed and added%the a uniform phase is introduced in the RF pulse stream; three pulses are addedclose all

%examines the fading of pulse/shapes%the program prompts the fractional delays

fc=10e3;%carrier frequencyppf=2*pi*fc;

fs=12*fc;%sampling rateddt=1/fs;

nn=1e-3/ddt;%total number of samples in one m secM=2^(nextpow2(nn))dist=1000;%distance between transmit and receive in meters

Page 62: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 62/246

Page 62 of 246

avdel=dist/3e8;%average delay in seconds

%kp*ku:kp*ku+1N=8;%number of bits

a=[1 1 -1 -1 -1 1 -1 1];kp=floor(nn/8);%creates the width of the pulse

for ku=1:8;for k=(ku-1)*kp+1:kp*kutt(k)=k*ddt;

s(k)=a(ku);%creates the pulse streamsf(k)=a(ku)*cos(ppf*tt(k));%rf pulsesf1(k)=a(ku)*cos(ppf*tt(k)+2*pi*rand(1));%random phase

sf2(k)=a(ku)*cos(ppf*tt(k)+2*pi*rand(1));%random phaseend;

end;

del=input('enter the fractional (of the duration) delay...between 0.25 and 0.75..');

dd1=round(del*kp);for k=1:kp*ku;

if k<=dd1ss1(k)=0;

else

ss1(k)=s(k-dd1);%creates a delayed pulse streamend;

end;del2=input('enter the fractional (of the duration) delay...between 0.25 and 0.75..');dd2=round(del2*kp);

for k=1:kp*ku;tt2(k)=k*ddt;

if k<=dd2ss2(k)=0;

else

ss2(k)=s(k-dd2);%creates a delayed pulseend;

end;sum=s+ss1+ss2;%added pulse shapessum=sum/max(abs(sum));%normalizes to unity

rfsum=sf+sf1+sf2;%added RF pulsesrfsum=rfsum/max(abs(rfsum));%normalizes to unity

plot(tt*1e3,s,tt*1e3,sf),title('bit stream [1 1 -1 -1 -1 1 -1 1]')ylim([-2 2]);

xlabel('time ms')ylabel('volts')

legend('input bit stream','input RF bit stream')

Page 63: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 63/246

Page 63 of 246

figure

plot(tt*1e3,sum,tt*1e3,rfsum),title('fading-effects of delay and random phase')ylim([-2 2]);

xlabel('time ms')ylabel('volts')

legend('bit stream in fading','RF bit stream in fading')

Page 64: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 64/246

Page 64 of 246

Problem 48. pulsefading

See the m file and results of the previous exercise (# 48)

Problem 49. pulsefadingRayl

clear%pulsefadingRayl.m fading including a carrier frequency

%three delays are created; Pulse stream is delayed and added%three pulses are added

%includes Rayleigh weighting at each time instant%the program prompts the fractional delaysclose all

%examines the fading of pulse/shapesfc=10e3;%carrier frequency

ppf=2*pi*fc;fs=12*fc;%sampling rateddt=1/fs;

Page 65: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 65/246

Page 65 of 246

nn=1e-3/ddt;%total number of samples in one m sec

M=2^(nextpow2(nn))dist=1000;%distance between transmit and receive in meters

avdel=dist/3e8;%average delay in seconds%kp*ku:kp*ku+1

N=8;%number of bitsa=[1 1 -1 -1 -1 1 -1 1];kp=floor(nn/8);%creates the width of the pulse

for ku=1:8;for k=(ku-1)*kp+1:kp*kutt(k)=k*ddt;

s(k)=a(ku);%creates the pulse streamss1(k)=a(ku)*raylrnd(1);%Rayleigh weighted

sf(k)=a(ku)*cos(ppf*tt(k));%rf pulsesf1(k)=raylrnd(1)*a(ku)*cos(ppf*tt(k));%rf pulse Rayleigh weighted

sf2(k)=raylrnd(1)*a(ku)*cos(ppf*tt(k));%rf pulse Rayleigh weighted

sf3(k)=raylrnd(1)*a(ku)*cos(ppf*tt(k));%rf pulse Rayleigh weightedend;

end;

del=input('enter the fractional (of the duration) delay...between 0.25 and 0.75..');

dd1=round(del*kp);for k=1:kp*ku;

if k<=dd1ss2(k)=0;

else

ss2(k)=s(k-dd1)*raylrnd(1);end;

end;del2=input('enter the fractional (of the duration) delay...between 0.25 and 0.75..');dd2=round(del2*kp);

for k=1:kp*ku;

if k<=dd2ss3(k)=0;

else

ss3(k)=s(k-dd2)*raylrnd(1);end;

end;sum=ss1+ss2+ss3;%added pulse shapes;Rayleigh weightedsum=sum/max(abs(sum));%normalizes to unity

rfsum=sf1+sf2+sf3;%added RF pulses Rayleigh weightedrfsum=rfsum/max(abs(rfsum));%normalizes to unity

plot(tt*1e3,s,tt*1e3,sf),title('bit stream [1 1 -1 -1 -1 1 -1 1]')ylim([-2 2]);

Page 66: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 66/246

Page 66 of 246

xlabel('time ms')

ylabel('volts')legend('input bit stream','input RF bit stream')

figureplot(tt*1e3,sum,tt*1e3,rfsum),title('Rayleigh weighted fading')

ylim([-2 2]);xlabel('time ms')ylabel('volts')

legend('bit stream in fading','RF bit stream in fading')

Page 67: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 67/246

Page 67 of 246

Problem 50. pulsefadingRayl

See exercise # 49.

Page 68: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 68/246

Page 68 of 246

Chapter 3

Page 69: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 69/246

Page 69 of 246

Problem 1 amps.m

clearclose all

%amps.m calculates the spectrum of the am and fm signals based on AMPS system%modulating signal is of frequency 4KHzN=4096*2;% use 2048 so that spectra are reasonably sharp

af=4e3;%carrier frequency of 40 KHz% one cannot use the carrier frequency (900 MHz) used in AMPS since the sampling rate

% would be very high and it will be difficult to show%the sidebands that will only be at a separtion of 4 KHz.mf=5e2;

beta=2;%modulation index for FMmu=0.2;%modulation index for AM

for p=1:N;t(p)=p/(60*af);%step size or sampling interval should be sufficient to prevent aliasing

%should be at least of the order of (1/2.max freq.)tt=t(p);

c(p)=cos(2*pi*af*tt);%carrier wavef2(p)=cos(2*pi*tt*mf);%modulating signalfreq(p)=cos(2*pi*af*tt+beta*sin(2*pi*tt*mf));

amp(p)=c(p)*(1.0+mu*f2(p));end

Ts=t(2)-t(1);Ws=2.*pi/Ts;

freqmax=0.5*Ws/(2*pi)FA=fft(amp);

FAMP=FA(1:N/2+1)*Ts;W=Ws*(0:N/2.)/N;% W is in radians/sWF=(1/(2*pi))*W;%WF is in cycles/s

FAM=fft(freq);FAMM=FAM(1:N/2+1)*Ts;

subplot(2,2,1);plot(t*1e3,amp);

%title('Carrier Freq: 40 KHz. AM signal- \mu=0.2');axis([0 4 -1.5 1.5]);

xlabel('time ms');ylabel('volts');subplot(2,2,2);

plot(t*1e3,freq);% title('Carrier Freq: 40 KHz. FM signal- \beta=3');

axis([0 4 -1.5 1.5]);

Page 70: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 70/246

Page 70 of 246

xlabel('time ms');

ylabel('volts');subplot(2,2,3);

plot(WF*1e-3,abs(FAMP)/max(abs(FAMP)));axis([0 8 0 1])

% title('Carrier Freq: 40 KHz. Spectrum of AM- \mu=0.2');xlabel('frequency KHz');ylabel('Normalized Spectrum');

subplot(2,2,4);plot(WF*1e-3,abs(FAMM)/max(abs(FAMM)));%title('Carrier Freq: 40 KHz. Spectrum of FM- \beta=3');

xlabel('frequency KHz');ylabel('Normalized Spectrum');

axis([0 8 0 1])

Problem 2. amps.m (previous exercise)

Page 71: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 71/246

Page 71 of 246

Problem 3. Let m(t) be the message signal. The DSB-SC signal then becomes

( ) ( ) ( )0cos 2is t m t f t π= . The average power of this signal is ( ) ( ) ( )2 2 2

0

1cos 2

2iS m t f t m t π= = .

The upper bar represents the average.

The signal coming out of the modulator will be

( ) ( ) ( ) ( ) ( ) ( ) ( ) ( )20 0 0 0

cos 2 cos 2 cos 2 cos 2o is t s t f t m t f t f t m t f t π π π π= = = . The average signal

power at the output will be ( ) ( )( ) ( )2

2

0 0cos 22 4

m t m t S m t f t π

= = =

, after the high frequency

component is removed. Comparing the input signal power to the demodulator ( )iS to the output

signal power ( )oS , we have2

io

S S = .

If n(t) is the noise at the input to the demodulator, the noise term becomes ( ) ( )0cos 2n t f t π . The

power corresponding to this term will be ( ) ( )2 20 1cos 2

2 2 4n t f t β βπ = =

. Note that we have

made use of the fact that the variance of the noise (which has zero mean) is nothing but the

spectral density given by2

β. If the bandwidth of the message signal is B, the filtered noise

power at the output of the demodulator, N0, will be0

24 2

B N B

β β = =

.

The signal-to-noise ratio at the output of the demodulator is

20

02

i

i

DSB SC

S

S

B B

S

N β β−

= =

.

SSB-SC:

The output signal-to-noise ratio remains unchanged because both the signal and noise occupy

only half the bandwidth and their respective powers go down by1

2leaving 0

0

S

N same as that for

BSB-SC.

Problem 4.

( ) ( ) ( ) ( ) ( ) ( ) ( )0

2 2 2

0 1 0 0 2 0 0 0cos 2 cos 2 2 cos 2out e t a a m t A f t a m t A f t m t A f t π π π = + + + + +

Page 72: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 72/246

Page 72 of 246

Figure Ex 3.4

The spectra of some of the terms are shown in Figure Ex 3.4. In the absence of the term m2(t),the minimum carrier frequency would have been 2W. However, the existence of the m2(t) term

requires that the minimum carrier frequency be at least equal to 3W to prevent distortion. Thecos2(2πf 0t) is filtered out. The carrier frequency can be lowered m(t)<<1, in which case we can

ignore m2(t). The minimum carrier frequency will then be 2W.

Problem 5% spectbrect.mclear%spectbrect.m calculates the spectrum of the BPSK

%pulses created using data points NNNNNN=[128 256 512];

for k=1:3NN=NNN(k);;N=1024;%number of samples to calculate FFT

fc=36/NN;for p=1:1:NN;

t(p)=p;

frequency

0 W 2W f 0 f 0+Wf 0-W

|eout(f)|m2(t)

m(t)

m(t)cos(2πf 0t)

cos(2πf 0t)

Page 73: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 73/246

Page 73 of 246

tt=t(p);

if (p>=0 & p<=NN/4);BPSK(p)=0.5;%

elseif (p>NN/4 & p<=NN/2);BPSK(p)=0.0;

else (p>NN/2);BPSK(p)=0.0;end;

end

for kk=NN+1:1:N;

BPSK(kk)=0.0;

t(kk)=kk;end;

Ts=t(2)-t(1);

Ws=2.*pi/Ts;freqmax=0.5*Ws/(2*pi);FB=fft(BPSK);

FBP=FB(1:N/2+1)*Ts;W=Ws*(0:N/2.)/N;% W is in radians/s

WF=(1/(2*pi))*W;%WF is in cycles/s%datarate DT;%DT=1/(NN/4);

%WWF=(WF)/DT;%freq units in data rate

FBMAX=max(abs(FBP));

for hh=1:1:N/2+1;

FFB(hh)=(abs(FBP(hh))/FBMAX);%BPSK

end;

plot(WF,(FFB.^2))

%ylim([-40 0])

%grid onaxis ontitle('normalized spectrum of rectangular pulse');

xlabel('frequency');ylabel('P(f)');

xlim([0 .05])hold on

Page 74: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 74/246

Page 75: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 75/246

Page 75 of 246

QP2(p)=0.0;

end;end

plot(t,QP1,t,QP2)xlabel('time Samples')

ylabel('volts')ylim([0 1])legend('unfiltered Siganl I','unfiltered Signal II')

%low pass filter the signals using Butterworth filters[b,a]=butter(10,.1);

QPL1=filtfilt(b,a,QP1);QPL2=filtfilt(b,a,QP2);

figureplot(t,QPL1,t,QPL2)xlabel('time Samples')

ylabel('volts')legend('filtered signal I','filtered signal II')

ylim([0 1])%two channel AMam1=QPL1.*cos(2*pi*t*30/NN);

am2=QPL2.*cos(2*pi*t*12/NN);am=am1+am2;%Am signal two channel

figureplot(t,am1,t,am2,t,am)xlabel('time Samples')

ylabel('volts')legend('signal I','signal II','AM')

figure[pxx1 f]=PSD(am,128,fs);%power spectrum of the AM signal showing two frequenciesplot(f,pxx1),title('power spectrum of the AM signal')

ylabel('volt^2')xlabel('frequency')

amq=QPL1.*cos(2*pi*t*30/NN)+QPL2.*sin(2*pi*t*30/NN);%QAM signalfigureplot(t,amq),title('Quadrature amplitude mod. signal')

xlabel('time Samples')ylabel('volts')

figure[pxx2 f]=PSD(amq,128,fs);%PSD of QAM signal showing only a single frequencyplot(f,pxx2),title('power spectrum of the QAM signal')

ylabel('volt^2')xlabel('frequency')

amd1=am.*cos(2*pi*t*30/NN );%multiplication with the first carrier[b,a]=butter(10,.1);amdd1=filtfilt(b,a,amd1);%low passfiltered signal

Page 76: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 76/246

Page 76 of 246

figure

plot(t,2*amdd1),title('demodulated output Signal I (AM)')xlabel('time Samples')

ylabel('volts')ylim([0 1])

amd2=am.*cos(2*pi*t*12/NN );%multiplication with the second carrieramdd2=filtfilt(b,a,amd2);%low filteringfigure

plot(t,2*amdd2),title('demodulated output Signal II (AM)')xlabel('time Samples')ylabel('volts')

ylim([0 1])%%%QAM recovery

amq1=amq.*cos(2*pi*t*30/NN);%multiplication by cosineamqq1=filtfilt(b,a,amq1);%low filteringamq2=amq.*sin(2*pi*t*30/NN);%multiplication by sine

amqq2=filtfilt(b,a,amq2);%low pass filteringfigure

plot(t,2*amqq1),title('demodulated output Signal I (QAM)')xlabel('time Samples')ylabel('volts')

ylim([0 1])figure

plot(t,2*amqq2),title('demodulated output Signal II (QAM)')xlabel('time Samples')ylabel('volts')

ylim([0 1])

Page 77: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 77/246

Page 77 of 246

Page 78: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 78/246

Page 78 of 246

Page 79: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 79/246

Page 79 of 246

Page 80: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 80/246

Page 80 of 246

Page 81: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 81/246

Page 81 of 246

Page 82: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 82/246

Page 82 of 246

Page 83: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 83/246

Page 83 of 246

Page 84: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 84/246

Page 84 of 246

Page 85: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 85/246

Page 85 of 246

Page 86: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 86/246

Page 86 of 246

Problem 10. Nyquistpulse.m

clearclose all

%Nyquistpulse.m, creates Nyquist's pulse and their spectra%calculates the spectra of the pulses

alpha=.9;%raised cosine roll off factoral=num2str(alpha);

T=4;%perioddt=1/(8*T);

N=4096;for kk=1:N;

m=-4*T+(kk)*dt;t(kk)=m;if m==0;

sincf(kk)=1;else

mp=pi*m;

sincf(kk)=sin(mp/T)/(mp/T);%sinc functionend;

Page 87: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 87/246

Page 87 of 246

factor=(1-(4.0*alpha*m/(2*T)).^2);

raic(kk)=sincf(kk)*cos(pi*m*alpha/T)/factor;%raised cosine pulseif (m>=-T/2 & m<=T/2)

rect(kk)=1;%rectangular pulsercp(kk)=0.5*(1+cos(2*pi*m/T));%RC pulse

else rect(kk)=0.0;rcp(kk)=0.0;

end;end;%N=1024;

ts=t(2)-t(1);Ws=2*pi/ts;

fre=fft(rect);fsi=fft(sincf);frc=fft(raic);

frcc=fft(rcp);frec=fre(1:N/2+1)*ts;%rect

fsinc=fsi(1:N/2+1)*ts;%sincfraic=frc(1:N/2+1)*ts;%raised cosinefrcf=frcc(1:N/2+1)*ts;%Full RC

f=(1/(2*pi))*Ws*(0:N/2)/N;figure (1)

subplot(2,2,1);t=t/T;plot(t,rect,'k');

title('rectangular pulse');axis([-4 4 -.4 1.4])

xlabel('multiples of T')set(gca,'xtick',[-4 -3 -2 -1 0 1 2 3 4]);grid on;

subplot(2,2,2)plot(t,sincf,'k'),title('sinc pulse');

axis([-4 4 -.4 1.4])set(gca,'xtick',[-4 -3 -2 -1 0 1 2 3 4]);xlabel('multiples of T')

grid on;subplot(2,2,3);

plot(t,raic,'k');xlabel('multiples of T')title(['raised cosine: \alpha ='al]);

axis([-4 4 -.4 1.4])set(gca,'xtick',[-4 -3 -2 -1 0 1 2 3 4]);

grid on;subplot(2,2,4);

Page 88: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 88/246

Page 88 of 246

plot(t,rcp,'k'),title('RC pulse');

axis([-4 4 -.4 1.4])set(gca,'xtick',[-4 -3 -2 -1 0 1 2 3 4]);

xlabel('multiples of T')

grid on;

figure (2)

subplot(2,2,1)

plot(f*T,abs(frec),'k'),title('rectangular pulse')xlim([0 4])

ylim([0 5])xlabel('multiples of 1/T')set(gca,'xtick',[0 1 2 3 4]);

grid on;

subplot(2,2,2)plot(f*T,abs(fsinc),'k'),title('sinc pulse');xlim([0 4])

ylim([0 5])xlabel('multiples of 1/T')

set(gca,'xtick',[0 1 2 3 4]);

grid on;

subplot(2,2,3);plot(f*T,abs(fraic),'k');

title(['raised cosine: \alpha ='al]);xlim([0 4])ylim([0 5])

xlabel('multiples of 1/T')set(gca,'xtick',[0 1 2 3 4]);

grid on;subplot(2,2,4);

plot(f*T,2*abs(frcf),'k'),title('RC pulse');xlim([0 4])

ylim([0 5])xlabel('multiples of 1/T')set(gca,'xtick',[0 1 2 3 4]);

grid on;

Page 89: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 89/246

Page 89 of 246

Problem 11. Nyquistpulse.m (see exercise # 10)

Page 90: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 90/246

Page 90 of 246

Problem 12. spectb.m

clear

%spectb.m calculates the spectrum of the a pulse and an RF pulseclose all

NN=128;N=1024;%number of samples to calculate FFTfc=36/NN;

for p=1:1:NN;t(p)=p;

tt=t(p);if (p>=0 & p<=NN/4);

BPSK(p)=0.5*cos(2*pi*tt*fc);%elseif (p>NN/4 & p<=NN/2);BPSK(p)=0.0;

else (p>NN/2);BPSK(p)=0.0;end;

end

Page 91: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 91/246

Page 91 of 246

for kk=NN+1:1:N;

BPSK(kk)=0.0;

t(kk)=kk;end;

Ts=t(2)-t(1);

Ws=2.*pi/Ts;freqmax=0.5*Ws/(2*pi);FB=fft(BPSK);

FBP=FB(1:N/2+1)*Ts;W=Ws*(0:N/2.)/N;% W is in radians/s

WF=(1/(2*pi))*W;%WF is in cycles/s%datarate DT;DT=1/(NN/4);

WWF=(WF)/DT;%freq units in data rate

FBMAX=max(abs(FBP));

for hh=1:1:N/2+1;

FFB(hh)=(abs(FBP(hh))/FBMAX);%BPSK

end;subplot(2,1,1);

plot(WWF,(FFB.^2)),title('normalized spectrum of RF pulse');xlabel('frequency R (data rate)');

ylabel('P(f)');%ylim([-40 0])%grid on

axis on

subplot(2,1,2);plot((WWF-fc/DT),(FFB.^2)),title('baseband spectrum');

xlabel('frequency R (data rate)');ylabel('M(f)');

%ylim([-40 0])xlim([0 10]);%grid on

axis on

Page 92: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 92/246

Page 92 of 246

Problem 13. specwaveforms.m

clear%specwaveforms.m calculates the spectrum of the BPSK,QPSK, and MSK wave forms(1

symbol)close all

NN=128;N=512;%number of samples to calculate FFTfor p=1:1:NN;

t(p)=p;tt=t(p);

if (p>=0 & p<=NN/4);BPSK(p)=0.5*cos(2*pi*tt*12/NN);%This is an RF signal ..

QPSK(p)=0.5*cos(2*pi*tt*12/NN);%This is an RF signal ..MSK(p)=0.5*cos(2*pi*tt*12/NN)*sin(pi*tt/(NN/2));%This is an RF signal ..elseif (p>NN/4 & p<=NN/2);

BPSK(p)=0.0;QPSK(p)=0.50*cos(2*pi*tt*12/NN);MSK(p)=0.5*cos(2*pi*tt*12/NN)*sin(pi*tt/(NN/2));

else (p>NN/2);BPSK(p)=0.0;

Page 93: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 93/246

Page 93 of 246

QPSK(p)=0.0;

MSK(p)=0.0;end;

end

for kk=NN+1:1:N;

BPSK(kk)=0.0;

QPSK(kk)=0.0;MSK(kk)=0.0;t(kk)=kk;

end;

Ts=t(2)-t(1);Ws=2.*pi/Ts;

freqmax=0.5*Ws/(2*pi);FB=fft(BPSK);

FBP=FB(1:N/2+1)*Ts;W=Ws*(0:N/2.)/N;% W is in radians/sWF=(1/(2*pi))*W;%WF is in cycles/s

%datarate DT;DT=1/(NN/4);

WWF=(WF-12/NN)/DT;%freq units in data rateFQ=fft(QPSK);FQP=FQ(1:N/2+1)*Ts;

FM=fft(MSK);FMP=FM(1:N/2+1)*Ts;

FQMAX=max(abs(FQP));FBMAX=max(abs(FBP));

FMMAX=max(abs(FMP));

for hh=1:1:N/2+1;

FFB(hh)=(abs(FBP(hh))/FBMAX);%BPSK

FFQ(hh)=(abs(FQP(hh))/FQMAX);%QPSKFFM(hh)=(abs(FMP(hh))/FMMAX);%MSK

end;

plot(WWF,FFB,'b',WWF,FFQ,'k',WWF,FFM,'r');

title('Spectra of Digital Waveforms');xlabel('Normalized Frequency (f-f_0)T');%shifted by the carrier frequencyylabel('|G(f)|');

Page 94: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 94/246

Page 94 of 246

axis([0 5.0 0 1]);

legend('BPSK','QPSK','MSK')

Problem 14. specfuncpower.m

clearclose all

%specfuncpower.m calculates the spectrum of the BPSK,QPSK, and MSK wave forms(1symbol)%no carrier modulation

%it also calculates the decrease in power in the sidebandsNN=128;

N=512;%number of samples to calculate FFTclose all

for p=1:1:NN;t(p)=p;tt=t(p);

if (p>=0 & p<=NN/4);BPSK(p)=0.5;QPSK(p)=0.5;

MSK(p)=0.5*sin(pi*tt/(NN/2));elseif (p>NN/4 & p<=NN/2);

Page 95: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 95/246

Page 95 of 246

BPSK(p)=0.0;

QPSK(p)=0.50;MSK(p)=0.5*sin(pi*tt/(NN/2));

else (p>NN/2);BPSK(p)=0.0;

QPSK(p)=0.0;MSK(p)=0.0;end;

end

for kk=NN+1:1:N;

BPSK(kk)=0.0;

QPSK(kk)=0.0;MSK(kk)=0.0;t(kk)=kk;

end;

Ts=t(2)-t(1);Ws=2.*pi/Ts;

freqmax=0.5*Ws/(2*pi);FB=fft(BPSK);

FBP=FB(1:N/2+1)*Ts;W=Ws*(0:N/2.)/N;% W is in radians/sWF=(1/(2*pi))*W;%WF is in cycles/s

%datarate DT;DT=1/(NN/4);

WWF=(WF)/DT;%freq units in data rateFQ=fft(QPSK);FQP=FQ(1:N/2+1)*Ts;

FM=fft(MSK);FMP=FM(1:N/2+1)*Ts;

FQMAX=max(abs(FQP));FBMAX=max(abs(FBP));

FMMAX=max(abs(FMP));

for hh=1:1:N/2+1;

FFB(hh)=(abs(FBP(hh))/FBMAX);%BPSK

FFQ(hh)=(abs(FQP(hh))/FQMAX);%QPSKFFM(hh)=(abs(FMP(hh))/FMMAX);%MSK

end;

Page 96: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 96/246

Page 96 of 246

plot(WWF,FFB,'b',WWF,FFQ,'k',WWF,FFM,'r');title('Spectra of Digital Waveforms');

xlabel('Normalized Frequency (f)T');ylabel('|G(f)|');

axis([0 5.0 0 1]);legend('BPSK','QPSK','MSK')%%%computes the power contained in the sidebands

NK=length(FFB)pb(1)=FFB(1)*FFB(1)*WF(1);pq(1)=FFQ(1)*FFQ(1)*WF(1);

pm(1)=FFM(1)*FFM(1)*WF(1);for k=2:NK;

pb(k)=pb(k-1)+FFB(k)*FFB(k)*WF(k);pq(k)=pq(k-1)+FFQ(k)*FFQ(k)*WF(k);pm(k)=pm(k-1)+FFM(k)*FFM(k)*WF(k);

end;figure

plot(WWF,pb/pb(NK),'b',WWF,pq/pq(NK),'k',WWF,pm/pm(NK),'r');title('Power contained');xlabel('Normalized Frequency fT');

ylabel('Power');xlim([0 5])

legend('BPSK','QPSK','MSK')

Page 97: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 97/246

Page 97 of 246

Problem 15.corrandconv.m

clear%corrandconv.m calculates the correlation and convolution of a rectangular pulse and a

sinusoidal pulseclose all

NN=128;N=512;%number of samples to calculate FFT

for p=1:1:NN;t(p)=p;

tt=t(p);BP(p)=1;

QP(p)=cos(2*pi*tt*12/NN);endxb=conv(BP,BP);

xq=conv(QP,QP);rb1=0;rq1=0;

for k=1:128;

Page 98: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 98/246

Page 98 of 246

rq(k)=QP(k)^2+rq1;%Correlation (integral up to T; T going from 1 to 128rb(k)=BP(k)^2+rb1;%Correlation (integral up to T; T going from 1 to 128

rb1=rb(k);rq1=rq(k);

end;

subplot(2,2,1)

plot(xb),title('convolution of the rectangular pulse')xlim([0 255])subplot(2,2,2)

plot(rb,'r'),title('correlation of the rectangular pulse')xlim([0 255])

subplot(2,2,3)plot(xq),title('convolution of the sine pulse')xlim([0 255])

ylim([-80 80])subplot(2,2,4)

plot(rq,'r'),title('correlation of the sine pulse')xlim([0 255])ylim([-80 80])

Page 99: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 99/246

Page 99 of 246

0 1 0 0 2 0 0

0

5 0

1 0 0

1 5 0

convolut ion of the rectangular pu lse

0 1 0 0 2 0 0

0

5 0

1 0 0

1 5 0

cor re lat ion of the rectangular pu lse

0 1 0 0 2 0 0

-50

0

5 0

convo lu t ion o f the s ine pu lse

0 1 0 0 2 0 0

- 5 0

0

5 0

cor re lat ion of the s ine pulse

T

TT

T

T=128

t ime

Problem 16. corrandconv.m (See Problem 15)

Problem 17.rocgennormal

clearclose all%closes all the curves on the screen

%rocgenNormal.m

%generates ROC from a set of Gaussian random numbers by%plotting the probability of false alarm vs prob. of detection

%inputs are the number of random numbers and the standard deviation%the means of the two sets are zero and 1 respectively

N=input('enter the number of Random numbers.....');

for kbr=1:100

ss=input('enter the standard deviation....');

Page 100: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 100/246

Page 100 of 246

x=normrnd(0,ss,1,N);%N Gaussian random numbers mean zero and std of ss

y=normrnd(1,ss,1,N);%N Gaussian random numbers mean 1 and std of ssmaxx=max(x);

minx=min(x);step=(maxx-minx)/N;

for mm=1:N;step1(mm)=minx+mm*step;count1=0;

count2=0;for k=1:N

if x(k)<=step1(mm)

count1=count1+1;else

end;if y(k)<=step1(mm)

count2=count2+1;

elseend;

end;PD(mm)=1-count2/N;PF(mm)=1-count1/N;

end;plot(PF,PD),title('ROC for Gaussian signals')

xlabel('Probability of false alarm')ylabel('Probability of detection')area_under_the_ROC_curve=0.5+polyarea(PF,PD)

hold onnm=input('enter 1 for another value of std dev and 0 to stop...')

if nm==0break

end

end;

Page 101: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 101/246

Page 101 of 246

Problem 18 rocgenRayleigh

clearclose all%closes all the curves on the screen%rocgenRay.m

%generates ROC from a set of Rayleigh random numbers by%plotting the probability of false alarm vs prob. of detection

%inputs are the number of random numbers the Rayleigh parameter bN=input('enter the number of Random numbers.....');for kbr=1:100

b1=input('Rayleigh parameter....');x=raylrnd(b1,1,N);% N Rayleigh random numbers with the parameter b

y=raylrnd(b1+1,1,N);%N Rayleigh random numbers with the parameter b+1

maxx=max(x);minx=min(x);

step=(maxx-minx)/N;for mm=1:N;

step1(mm)=minx+mm*step;count1=0;count2=0;

for k=1:N

Page 102: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 102/246

Page 102 of 246

if x(k)<=step1(mm)

count1=count1+1;else

end;if y(k)<=step1(mm)

count2=count2+1;elseend;

end;PD(mm)=1-count2/N;PF(mm)=1-count1/N;

end;plot(PF,PD),title('ROC for Rayleigh signals')

xlabel('Probability of false alarm')ylabel('Probability of detection')area_under_the_ROC_curve=0.5+polyarea(PF,PD)

hold on

nm=input('enter 1 for another value of std dev and 0 to stop...')if nm==0

break

endend;

Problem 19. rocgenNormal and rocgenRay.m (See the two previous exercises)

Problem 20

clear

%problem320.mfor b=1:1:15;% sn is the signal to noise ratio in DBs;

sn(b)=b;snr(b)=10.0^(b/10);

xx=erfc(sqrt(snr(b)));bpsk(b)=0.5*xx;%BPSK no fadingdpsk(b)=0.5*exp(-snr(b));%DPSK no fading

end;

figure (1)semilogy(sn,bpsk,'r',sn,dpsk,'k'); %y axis is log;legend('BPSK','DPSK')

Page 103: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 103/246

Page 103 of 246

axis([1.0 15.0 .00001 0.1]);

xlabel('signal-to-noise ratio dB')ylabel('probability of error')

2 4 6 8 10 12 14

10-4

10-3

10-2

10-1

signal-to-noise ratio dB

p r o b a b i l i t y

o f e r r o r

eqn. 3.84eqn. 3.105

Problem 21. The output of the integrator will either be

( ) ( ) ( )2

0 0

0 0

cos 2 cos 22

T T T

A f t dx n t f t dx A nπ π+ = +∫ ∫

where n will be zero mean Gaussian with a variance of 0

2 2

N T

or

( ) ( )0

0

cos 2T

n t f t dx nπ =∫ .

Page 104: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 104/246

Page 104 of 246

The two hypotheses now become

1 , '1'

' 0 '

r n

r n

==

where n and n1 are Gaussian random variables with identical variances of 0

2 2

N T

, with n

having zero mean and n1 having a mean of 2

T A

. These two Gaussian random variables are

shown in Figure Ex 3.20S, with the decision boundary. The threshold will be the midway point,

4

T A .

The probability of false alarm and probability of miss are indicated in the figure and they will be

equal. Therefore, the error probability given by

( )2

m is s fa lse ala rm

false alarm

P PP e P

+= = .

( )

2

22

20

4

exp 1 1

2 2 24 22

n

T A

AT E P e dn erfc erfc

N

σ

σπσ

−∞ = = = ∫ .

Problem 22. The output of the integrator will either be

( ) ( ) ( )2

0 0

0 0

cos 2 cos 22

T T T

A f t dx n t f t dx A nπ π+ = +∫ ∫

where n will be zero mean Gaussian with a variance of 0

2 2

N T

or

( ) ( ) ( )2

0 0

0 0

cos 2 cos 22

T T T

A f t dx n t f t dx A nπ π− + = − +∫ ∫ .

The two hypotheses now become

Page 105: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 105/246

Page 105 of 246

1

2

, '1'

'0 '

r n

r n

==

where n1 and n2 are Gaussian random variables with identical variances of 0

2 2

N T , with n n1

having a mean of 2

T A

and n2 having a mean of 2

T A− . These two Gaussian random variables

are shown in Figure Ex 3.21S, with the decision boundary. The threshold will be the midwaypoint, i.e. 0.

The probability of false alarm and probability of miss are indicated in the figure and they will beequal. Therefore, the error probability given by

( ) 2

m is s fa lse ala rm

false alarm

P P

P e P

+= = .

( )

2

2

2

2

200

exp 1 1

2 22 22

T n A

AT E P e dn erfc erfc

N

σ

σπσ

+ −∞

= = = ∫ .

Problem 23.BPSASKsim.m

clearclose all

%BPSASKsim.m%generates OOK and BPSK signals

%adds noise%coherent demodulation followed by LPF%OOK signal is also detected incoherently

close allfc=10e3;%carrier frequency

ppf=2*pi*fc;

fs=12*fc;%sampling rateddt=1/fs;

nn=1e-3/ddt;%total number of samples in one m secM=2^(nextpow2(nn))

N=8;%number of bitsa=[1 1 -1 -1 -1 1 -1 1];%for BPSKb=[1 1 0 0 0 1 0 1];%for ASK

kp=floor(nn/8);%creates the width of the pulse

Page 106: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 106/246

Page 106 of 246

sd=input('enter the std dev.of additive white noise 0.01 to .7 ..');

for ku=1:8;

for k=(ku-1)*kp+1:kp*kutt(k)=k*ddt;

s(k)=a(ku);%creates the pulse streamsa(k)=b(ku);%ASK datasf(k)=a(ku)*cos(ppf*tt(k))+normrnd(0,sd);%rf signal plus noise BPSK

sam(k)=b(ku)*cos(ppf*tt(k))+normrnd(0,sd);%rf signal plus noise ASK signalend;

end;

plot(tt*1e3,s,tt*1e3,sf),title('data and BPSK signal')ylim([-4 4])

legend('Data','BPSK signal')figureplot(tt*1e3,sa,tt*1e3,sam),title('data and OOK signal')

ylim([-4 4])legend('Data','OOK signal')

for k=1:kp*8;sfd(k)=sf(k)*2*cos(ppf*tt(k));%coherent demodulationsamd(k)=sam(k)*2*cos(ppf*tt(k));%coherent demodulation OOK signal

end;[bb,aa]=butter(5,.2);

sfd=filtfilt(bb,aa,sfd);samd=filtfilt(bb,aa,samd);figure

plot(tt*1e3,s,tt*1e3,sfd)legend('Data','BPSK demodulated data')

ylim([-4 4])figureplot(tt*1e3,sa,tt*1e3,samd)

ylim([-4 4])legend('Data','OOK demodulated data')

sq1=sam.^2;%square the OOK signalssq=sqrt(sq1);%gets the envelope by taking the square root

sq2=filtfilt(bb,aa,ssq);figure

plot(tt*1e3,sa,tt*1e3,sq2)ylim([-4 4])legend('Data','OOK envelope detected data')

Page 107: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 107/246

Page 107 of 246

Problem 24. BPSASKsim.m

Page 108: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 108/246

Page 108 of 246

Problem 25.

Input1 0 0 1 1 1 0 1 0

DPSK encoded bits

1 1 0 1 1 1 1 0 0 1Transmitted phases

0 0 π 0 0 0 0 π π 0

Problem 26. The phases are based on the following phase constellation

1 1 π/4−1 1 3π/4−1 −1 5π/41 −1 7π/4

1 1−1 1

−1 −1 1 −1

Page 109: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 109/246

Page 109 of 246

1 0 0 1 1 1 0 1I Q I Q I Q I Q

Phases 7π/4 3π/4 π/4 3π/4Phase shifts π π/2 − π/2

Problem 27.

Problem 28. qpq.m

clear;close all

%qpq.m%creates a sequential way to generate QPSK waveformsN=8;%number of bits

T=100;%bit duration units

a=[1 1 -1 -1 -1 1 1 1];fc=1/100;% minimum carrier freq; higher values may not show phase changes clearly

for jj=1:N/2;

pp=2*jj-1;%creates the counter for the symbolsfor kk=2*T*(jj-1)+1:2*T*jj;

x(kk)=kk;

1 1

-1 -1 1 -1

-1 1

1 0 1 0

0 1 1 1

Phase shift π /2 π /2 π /2 0 -π /2 0

7π /45π /4

3π /4π /4

π /43π /4

3π /4

Page 110: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 110/246

Page 110 of 246

qpsk1(kk)=(a(pp)*cos(2*pi*fc*kk)+a(pp+1)*sin(2*pi*fc*kk))/sqrt(2);%carrier wave

cos(2*pi*fc*t)

qpsk2(kk)=(a(pp)*cos(2*pi*fc*kk+pi/4)+a(pp+1)*sin(2*pi*fc*kk+pi/4))/sqrt(2);%cos(2*pi*fc*t+pi/4)

end;end;subplot(2,1,1)

plot(x/T,qpsk1,'k.'),title('QPSK')subplot(2,1,2);plot(x/T,qpsk2,'k.'),title('QPSK (shifted by \pi /4)')

Problem 29 oqpq.m

clear;

close all%oqpq.m

%creates a sequential way to generate OQPSK waveformsN=8;%number of bitsT=100;%bit duration units

a=[1 1 -1 -1 -1 1 1 1];

Page 111: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 111/246

Page 111 of 246

fc=1/100;% minimum carrier freq; higher values may not show phase changes clearly

for jj=1:N/2;

pp=2*jj-1;%creates the counter for the symbolsfor kk=2*T*(jj-1)+1:2*T*jj;

x(kk)=kk;ai(kk)=a(pp)*cos(2*pi*fc*kk);%in phase terms unshiftedaq(kk)=+a(pp+1)*sin(2*pi*fc*kk);% quadrature terms shifted

end;end;

for pq=1:(N-1)*T;xx(pq)=pq;

opsk(pq)=(ai(pq+100)+aq(pq))/sqrt(2.0);%first term creates shifted in phase termsend;

plot(xx/T,opsk,'k.'),title('OQPSK')axis([0 7 -1 1])

Problem 30 p4qp.m

Page 112: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 112/246

Page 112 of 246

clear;

close all%p4qp.m

%creates a sequential way to generate pi/4QPSK waveforms...simple programN=8;%number of bits

T=100;%bit duration unitsa=[1 1 -1 -1 -1 1 1 1];fc=1/100;% minimum carrier freq; higher values may not show phase changes clearly

ph=1;for jj=1:N/2;

ph1(jj)=ph;

ph=abs(ph-1);if ph1(jj)<=0;

phase=pi/4;else

phase=0;

end;pp=2*jj-1;%creates the counter for the symbols

for kk=2*T*(jj-1)+1:2*T*jj;x(kk)=kk;

p4sk(kk)=(a(pp)*cos(2*pi*fc*kk+phase)+a(pp+1)*sin(2*pi*fc*kk+phase))/sqrt(2);

end;end;

plot(x/100,p4sk,'k.');title('\pi/4QPSK')

Page 113: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 113/246

Page 113 of 246

Problem 31. p4qpac.m

clear;close all

%p4dqpac.m%creates a sequential way to generate pi/4DQPSK waveforms...simple program

% Note that the once the phase is differntailly encoded, thre is no need%to switch between constellations.N=8;%number of bits

T=100;%bit duration unitsa=[1 1 -1 -1 -1 1 1 1];

fc=1/100;% minimum carrier freq; higher values may not show phase changes clearly

pph=0.0;%accumulated phasefor jj=1:N/2;

pp=2*jj-1;%creates the counter for the symbols

c=a(pp)+a(pp+1)*i;%this is to calculate the phase angle of the symbolcc=angle(c);phe=cc+pph; %pph is the accumulated phase

for kk=2*T*(jj-1)+1:2*T*jj;

Page 114: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 114/246

Page 114 of 246

x(kk)=kk;

p4dsk(kk)=cos(phe)*cos(2*pi*fc*kk+pi/4)+sin(phe)*sin(2*pi*fc*kk+pi/4);%there is no need to divide by sqrt(2.0) if one is using cos or sin of phase

% instead of 1 and -1end;

pph=phe;end;plot(x/100,p4dsk,'*');

title('\pi/4 DQPSK')

Page 115: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 115/246

Page 115 of 246

Problem 32. Symbol rate = 0.5x104 symbols/s

Problem 33.

(a) The BER of the QPSK scheme is the same as the BER of BPSK. The symbol error rate of

the QPSK is twice the BER, equal to 42 10−× .

(b) 2 120QPSK BPSK BW BW kHz= = .

(c) Spectral efficiency of QPSK is twice the spectral efficiency of BPSK.

(d) 8 3 180levelPSK BPSK BW BW kHz− = = .

(e) 1.5 90 MSK BPSK BW BW kHz= = .

Problem 34 .msk.mclear;

close all%msk.m%creates a sequential way to generate MSK waveforms

N=8;%number of bitsT=100;%bit duration units

a=[1 1 -1 -1 -1 1 1 1];fc=1/100;% minimum carrier freq; higher values may not show phase changes clearlyfs=1/400;%carrier frequency for MSK

for jj=1:N/2;

pp=2*jj-1;%creates the counter for the symbolsfor kk=2*T*(jj-1)+1:2*T*jj;x(kk)=kk;

ai(kk)=a(pp)*cos(2*pi*fc*kk);%in phase terms unshifted

aq(kk)=a(pp+1)*sin(2*pi*fc*kk);% quadrature terms unshifted

end;end;

1 1

−1 1

−1 −1 1 −1

Page 116: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 116/246

Page 116 of 246

for pq=1:(N-1)*T;

xx(pq)=pq;mskw(pq)=(ai(pq+100)*cos(2*pi*fs*pq)+aq(pq)*sin(2*pi*fs*pq));%first term creates shifted

in phase termsend;

plot(xx/T,mskw,'k.'),title('MSK')axis([0 7 -1 1])

Problem 35 .mskdf.m

clear;%mskdf%creates MSK waveforms using DFM;

N=8;T=100;%bit duration unitsa=[1 1 -1 -1 -1 1 1 1];

fc=1/100;% minimum carrier freq; higher values may not show phase changes clearlywc=2*pi*fc;%carrier freq. in radians

Page 117: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 117/246

Page 117 of 246

msf=2*pi/(4*T);%msk frequency

phase=0.0;for jj=1:N;

for kk=T*(jj-1)+1:T*jj;x(kk)=kk;

xkk=kk-(jj-1)*T;msk(kk)=cos(msf*a(jj)*xkk+wc*kk+phase);end;

phase=phase+a(jj)*pi/2;end;

plot(x/100,msk,'*')

title('[1 1 -1 -1 -1 1 1 1]');axis([0 8 -1 1])

Problem 36.fsk.m

clear

%fsk.m;creates a FSK signalT=100;%bit durationN=8;%number of bits

a=[1 1 -1 -1 1 1 1 1];fc=1/100;%carrier frequency

Page 118: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 118/246

Page 118 of 246

step=1;%number of points in 1 sec

for jj=1:Nfor kk=T*(jj-1)+1:T*N;

x(kk)=kk;%time axisxfsk(kk)=cos(2*pi*(fc+a(jj)/400)*kk);%carrier frequency 1..fc+ 1/(4*T) or fc-

1/(4*T)end;end;

plot(x/100,xfsk);title('FSK')

ylim([-1.5 1.5])

Problem 37. spec.m

clear%spec.m calculates the spectrum of the BPSK,QPSK, and MSK wave forms(1 symbol)

NN=128;N=512;%number of samples to calculate FFT

Page 119: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 119/246

Page 119 of 246

for p=1:1:NN;t(p)=p;

tt=t(p);if (p>=0 & p<=NN/4);

BPSK(p)=0.5*cos(2*pi*tt*12/NN);QPSK(p)=0.5*cos(2*pi*tt*12/NN);MSK(p)=0.5*cos(2*pi*tt*12/NN)*sin(pi*tt/(NN/2));

elseif (p>NN/4 & p<=NN/2);BPSK(p)=0.0;QPSK(p)=0.50*cos(2*pi*tt*12/NN);

MSK(p)=0.5*cos(2*pi*tt*12/NN)*sin(pi*tt/(NN/2));else (p>NN/2);

BPSK(p)=0.0;QPSK(p)=0.0;MSK(p)=0.0;

end;end

for kk=NN+1:1:N;

BPSK(kk)=0.0;QPSK(kk)=0.0;

MSK(kk)=0.0;t(kk)=kk;end;

Ts=t(2)-t(1);Ws=2.*pi/Ts;freqmax=0.5*Ws/(2*pi);

FB=fft(BPSK);FBP=FB(1:N/2+1)*Ts;

W=Ws*(0:N/2.)/N;% W is in radians/sWF=(1/(2*pi))*W;%WF is in cycles/s%datarate DT;

DT=1/(NN/4);WWF=(WF-12/NN)/DT;%freq units in data rate

FQ=fft(QPSK);FQP=FQ(1:N/2+1)*Ts;FM=fft(MSK);

FMP=FM(1:N/2+1)*Ts;

FQMAX=max(abs(FQP));FBMAX=max(abs(FBP));FMMAX=max(abs(FMP));

Page 120: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 120/246

Page 120 of 246

for hh=1:1:N/2+1;

FFB(hh)=(abs(FBP(hh))/FBMAX);%BPSKFFQ(hh)=(abs(FQP(hh))/FQMAX);%QPSK

FFM(hh)=(abs(FMP(hh))/FMMAX);%MSKend;

plot(WWF,FFB,'b',WWF,FFQ,'k',WWF,FFM,'r');

title('Spectra of Digital Waveforms');xlabel('Normalized Frequency (f-f_0)T');

ylabel('|G(f)|');axis([0 5.0 0 1]);legend('BPSK','QPSK','MSK')

Page 121: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 121/246

Page 121 of 246

Problem 38. gmshape.m

clear

close all% gmshape.m calculates the shape of the pulse

% only the effect of one pulse passing thro' the Gaussian filterT=64;N=7*T;%number of pionts for plotting

MM=4;% we are looking at the 4th pulse onlyM1=(MM-1)*T;

M2=MM*T;bt1=.15;%B.T for GMSK calculationbt2=.3;

bt3=.5;bt4=10;

B01=bt1/T;% bandwidthB02=bt2/T;

B03=bt3/T;B04=bt4/T;

a1=(0.5887/B01);% alphaa2=(0.5887/B02);

a3=(0.5887/B03);a4=(0.5887/B04);

si1=a1/(sqrt(2.0)*pi);% sigma for the Gaussian impulse response

sip1=si1*sqrt(2.0);%sqrt(2)*sigmasi3=a3/(sqrt(2.0)*pi);sip3=si3*sqrt(2.0);si2=a2/(sqrt(2.0)*pi);

sip2=si2*sqrt(2.0);si4=a4/(sqrt(2.0)*pi);

sip4=si4*sqrt(2.0);T4=1/(4*T);

for p=1:1:N;tt(p)=p;

G1(p)=T4*(erfc((M1-p)/sip1)-erfc((M2-p)/sip1));G2(p)=T4*(erfc((M1-p)/sip2)-erfc((M2-p)/sip2));

G3(p)=T4*(erfc((M1-p)/sip3)-erfc((M2-p)/sip3));G4(p)=T4*(erfc((M1-p)/sip4)-erfc((M2-p)/sip4));

end;

GMSK1=G1/max(G1);

Page 122: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 122/246

Page 122 of 246

GMSK2=G2/max(G2);

GMSK3=G3/max(G3);GMSK4=G4/max(G4);

t=tt/T;%time in units of bit duration

set(0,'DefaultAxesXgrid','on');set(0,'DefaultAxesYgrid','on');

plot(t,G1/max(G4),'k',t,G2/max(G4),'k',t,G3/max(G4),'k',t,G4/max(G4),'k');%title('GMSK Pulse Shape');

xlabel('time xT');ylabel('amplitude');

ylim([0 1.2])

Problem 39 .eyepat.m

clear%eyepat.m creates the eye pattern for a rectangular pulse stream being low% pass filtered. bt=100 corresponds to infinite bandwidth

%automatically produces the title. It plots 4 figures at a time using subplots

Page 123: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 123/246

Page 123 of 246

pi2=sqrt(2*pi);

si=0.05;%standard deviation for noiseN=16;%number of bits, minimum number so that the tails will show up

%the tails will extend over several bitsT=50;% bit (duration)

T4=4*T;% note that in this case the pulse height is (1/(2T);%bt=1000;%B.T is the GMSK parameter; Here this determines the 3dB BW of the LPFkt=1;

for kh=1:10;bt=input('enter the value of BT...>');yn=input('enter 1 if noise is to be added and 0 for no noise..>');

B=bt/T;%bandwidthalpha=0.5887/B;

sigma=alpha/(sqrt(2.)*pi);sig=sqrt(2.0)*sigma;

subplot(2,2,kt)%Note a maximum of four figures only

%We have a rectangular pulse passing through a Gaussian LPF with a bandwidth Bfor uu=1:20;for kk=1:N;

yr=rand(1);if yr<=.5

a(kk)=-1;else

a(kk)=1;

end;end;

for kq=1:N*T;xx(kq)=kq;

y=0.0;

for kn=1:N;knt=kn*T-xx(kq);

knt1=(kn-1)*T-xx(kq);y=y+(1/T4)*a(kn)*(erfc(knt1/sig)-erfc(knt/sig));%creates the total pulse shape

end;

if yn==1;yy(kq)=y+0.05*y*randn(1);%adds noise

elseyy(kq)=y;end;

end;

maxy=max(abs(yy));%figure (kt)plot(xx/T,yy/maxy);

Page 124: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 124/246

Page 124 of 246

hold on

end;axis([2 4 -1.2 1.2])

BT=num2str(bt);%creates a stringif yn==1;

fname= strcat('BT=',BT,' noise present');elsefname=strcat('BT=',BT);%gives BT=appropriate value

end;title(fname)xlabel('\fontnamecourier \fontsize10 t/T');

kt=kt+1;hold off;

pr=input('enter 1 for more, and 0 to stop.....>');if pr==0

break

elseend;

end;

Problem40. eyepat.m

Page 125: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 125/246

Page 125 of 246

Problem 41.gmphase.m

clearclose all%gmphase.m to see the integral becomes 0.5 for the GMSK analytical expression

% as t goes to T;T=100;

bbt=[0.1 0.2 0.3 0.5 50]%Bt valuesfor kt=1:5;

%bt=.5;

bt=bbt(kt);B=bt/T;%bandwidth

alpha=0.5887/B;

pi2=sqrt(2*pi);sigma=alpha/(sqrt(2.)*pi);

sig=sqrt(2.0)*sigma;T4=4*T;

si2=sig*sig;sip=2.0*sigma/sqrt(2.0*pi);

kn=10;%looking at the 10th pulse

Page 126: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 126/246

Page 126 of 246

for kq=T:20*T;

tt(kq)=kq;t=kq-1;%integration up point; t

Tn=kn*T-t;%NT-t;Tn1=(kn-1)*T-t;%((N-1)*T-t;

TT=kn*T;TT1=(kn-1)*T;aa1=TT*erf(TT/sig);

aa2=Tn*erf(Tn/sig);aa3=sip*(exp(-(Tn.^2)/si2)-exp(-(TT.^2)/si2));

bb1=TT1*erf(TT1/sig);bb2=Tn1*erf(Tn1/sig);

bb3=sip*(exp(-(Tn1.^2)/si2)-exp(-(TT1.^2)/si2));etot=aa1-aa2-aa3-(bb1-bb2-bb3);%creates the total integral allowing the effect of tphase(kq)=etot/T4;

end;

plot((tt/T-9),tphase,'k');axis([-5 5 -0.1 .6])axis on;

grid onhold on;

end;

ylabel('phase term')

Page 127: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 127/246

Page 127 of 246

Problem 42.gmsk.m

clear%gmsk.m

%generates gmsk waveformsT=100;%bit duration

N=8;%the number of bitsa= [1 1 -1 -1 -1 1 1 1];

bt=input('enter the value of BT..>>')B=bt/T;%bandwidth

alpha=0.5887/B;pi2=sqrt(2*pi);

sigma=alpha/(sqrt(2.)*pi);carf=1/100;%carrier frequencyh=0.5;%modulaion index

sig=sqrt(2.0)*sigma;sip=2*sigma/sqrt(2.0*pi);;T4=4*T;

T2=2*T;si2=sig*sig;

Page 128: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 128/246

Page 128 of 246

carf=1/T;%carrier frequency

h=0.5;%modulaion indexyy(1)=0.0;%the first integral t=0 to t=0 is zero.

%t goes from 0-99 eventhough the samples are from 1-100for kq=2:N*T;%assumed that the samplig rate is 1;

y=0.0;

for kn=1:N;

t=kq-1;%integration up point; tTn=kn*T-t;%NT-t;Tn1=(kn-1)*T-t;%((N-1)*T-t;

TT=kn*T;TT1=(kn-1)*T;

aa1=TT*erf(TT/sig);aa2=Tn*erf(Tn/sig);aa3=sip*(exp(-(Tn.^2)/si2)-exp(-(TT.^2)/si2));

bb1=TT1*erf(TT1/sig);

bb2=Tn1*erf(Tn1/sig);bb3=sip*(exp(-(Tn1.^2)/si2)-exp(-(TT1.^2)/si2));etot=aa1-aa2-aa3-(bb1-bb2-bb3);

y=y+(1/T4)*a(kn)*etot;%creates the total integral allowing the effect of end;

yy(kq)=y;end;for kx=1:N*T;

x(kx)=kx;gmsk(kx)=cos(2*pi*carf*kx+2*pi*h*yy(kx));

end;BT=num2str(bt);fname=strcat('gmsk ',' BT= ',BT)

plot(x/100,gmsk,'+'),title(fname);

xlabel('time ms')ylabel('amplitude')

ylim([-1 1])

Page 129: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 129/246

Page 129 of 246

Problem 43. gmspfnal.m

clear% gmspfnal.m calculates the spectrum of the GMSK modulated waveform

%takes complete overlap. The integral for each bit is calculated including%the contribution from all bits and is found outside the loop so that

%integral values may be reused with appropriate weighting when new bit%sequences are created for Spectral averaging%bt=[0.2 0.3 .5 .7 1. 1000];%GMSK parameter

T=128;N=32;

T2=2*T;M=2.^nextpow2(T*N);%number of samples to calculate FFT; next pow2% gets the M to be equal to an integer multiple of 2 next to T*N

bt=0.3;B=bt/T;%bandwidth

alpha=0.5887/B;pi2=sqrt(2*pi);sigma=alpha/(sqrt(2.)*pi);

carf=1/T;%carrier frequency

Page 130: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 130/246

Page 130 of 246

h=0.5;%modulaion index

sig=sqrt(2.0)*sigma;T4=4*T;

si2=sig*sig;sip=2*sigma/sqrt(2.0*pi);

fxx=zeros(1,M/2+1);%creates initial values for averaging%*** calculates the integral values outsideyy(1)=0.0;%the first integral t=0 to t=0 is zero.

%t goes from 0-99 eventhough the samples are from 1-100for kq=2:N*T;%assumed that the samplig rate is 1;for kn=1:N;%considers complete overlap

t=kq-1;%integration up point; tTn=kn*T-t;%NT-t;

Tn1=(kn-1)*T-t;%((N-1)*T-t;TT=kn*T;TT1=(kn-1)*T;

aa1=TT*erf(TT/sig);aa2=Tn*erf(Tn/sig);

aa3=sip*(exp(-(Tn.^2)/si2)-exp(-(TT.^2)/si2));

bb1=TT1*erf(TT1/sig);

bb2=Tn1*erf(Tn1/sig);bb3=sip*(exp(-(Tn1.^2)/si2)-exp(-(TT1.^2)/si2));

etot(kq,kn)=aa1-aa2-aa3-(bb1-bb2-bb3);%creates the total integral allowing the effect of complete overlapend;

end;%*** calculates the integral values outside

for ap=1:25;%for averaging the spectra

for kq=1:N;%creates random values of + or -1

yr=rand(1);if yr<=0.5;a(kq)=1.0;

elsea(kq)=-1;

end;end;

for mq=2:N*T;%assumed that the sampling rate is 1;y=0.0;

for mn=1:N;%considers complete overlapy=y+(1/T4)*a(mn)*etot(mq,mn);%creates the total integral allowing the effect of effect of

complete overlap

Page 131: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 131/246

Page 131 of 246

end;

yy(mq)=y;end;

for kx=1:N*T;

x(kx)=kx-1;gmsk(kx)=cos(2*pi*carf*kx+2*pi*h*yy(kx));end;

for jp=N*T+1:Mx(jp)=jp-1;

gmsk(jp)=0.0;end;

[pxx,f]=psd(gmsk,M,1);%generates M/2+1 output points

for uu=1:M/2+1;%performs averaging of 'psd's from each iteration

fp=fxx(uu);fxx(uu)=fp+pxx(uu);

end;end;

pxxdb=10*log10((fxx)/max(fxx));% Power spectral density in dBplot((f-carf)*T,pxxdb);

axis([0 5 -100 0])xlabel('Normalized Frequency (f-f_0)T');

ylabel('Power Spectral Density (dB)')title('Power Spectrum of GMSK')

grid on;hold on;

Page 132: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 132/246

Page 132 of 246

Problem 44. Show that a 4-levl PSK and 4 – level QAM are equivalent.

Four level PSK

Four level QAM (version I) Four level QAM (version 2)

If all the signals are equally likely, the average power for 4 level PSK and 4 level QAM (version

I) = 2 2 2 2 212 2 2 2 2

4 A A A A A × + + + = .

For the 4 level QAM (version 2), if the circles of the radii are 3 Aand A (which will make the

minimum distance between the symbols in QAM and PSK the same),

the average power = 2 2 2 2 213 3 2

4

A A A A A × + + + = .

Thus, the average powers of 4 level PSK and 4 level QAM are the same.

Problem 45. The bit error rate or the probability of error, BER, of a coherent BPSK system is

given by

0

1

2

E BER erfc

N =

where 2

2

T E A= . The amplitude is given by A and the data rate

1 R

T = . The noise power spectral

density is given by N0. Rewriting the equation for the error rate and expressing erfc function interms of erf function to take advantage of erfinv, we get

d =2A

2 2

1 2d A A= +

1 A

2 A

Page 133: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 133/246

Page 134: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 134/246

Page 134 of 246

function y=fun(xy)

%for the computation of BER when phase mismatch is randomglobal ssf

global snrxx=tan(xy);

xx2=xx.^2;x1=sec(xy);x2=x1.^2;

ssf2=2*ssf*ssf;ex=exp(-xx2/ssf2);yy=cos(xx)*sqrt(snr);

y=(1/sqrt(pi*ssf2))*0.5*ex.*erfc(yy).*x1.*x1;

Problem 48.

%qpskphasemis.m%calculates the degradation brought on by the pahse mismatch in QPSK

%BER for three vlaues of mismatchclearclose all

angle=[0 10 20];angler=angle*pi/180;%mismatch in radians

Page 135: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 135/246

Page 135 of 246

for kk=1:3

xr=angler(kk)for k=1:21;

snr(k)=k;%SNRsn=10^(k/10);

sn1=sqrt(sn);ax=cos(xr)+sin(xr);snx=sn1*ax;

ay=cos(xr)-sin(xr);sny=sn1*ay;pe(k)=0.25*(erfc(snx)+erfc(sny));

end;semilogy(snr,pe,'r');

xlabel('SNR dB');ylabel('probability of error p_\Delta\phi(e)')ylim([0.000001 .5])

xlim([2 20])hold on

end;

Page 136: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 136/246

Page 136 of 246

Problem 49 p4dqpskerr.m

clear

%p4dqpskerr.m%computes the ber of p/4 DQPSK for baseband differential detection

for k=1:20;sn(k)=k;%signal-to-noise raio in dB

snr=10.^(k/10);ex=exp(-2*snr);

ee=sqrt(2)*snr;bbx=0.0;for kk=1:101;

ks=kk-1;ax=(sqrt(2)-1)^ks;

bx=ax*besseli(ks,ee);

bbx=bx+bbx;end;

dqpsk(k)=ex*(bbx-0.5*besseli(0,ee));%pi/4 DQPSKxx=erfc(sqrt(snr));

bpsk(k)=0.5*xx;%BPSK no fading

end;

semilogy(sn,dqpsk,sn,bpsk);ylim([0.000001 .5])

Page 137: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 137/246

Page 137 of 246

Problem 50 pskmargin.m

clearclose all

%pskmargin.m%computes the power margin as a function of the bit error rate for BPSK (Coherent) and DPSK.

for k=1:1001;ber(k)=1e-6*(k-1)*10;be2=2*ber(k);

ZB=(erfinv(1-be2))^2;%SNR required in BPSKZD=-log(be2);%SNR required in DPSK

ZFD=1/((1/(1-be2))^2-1);%SNR required in fading coherent BPSKZDD=1/be2-1;%SNR required in fading DPSK

CtoDP(k)=10*log10(ZD)-10*log10(ZB);%excess snr required to have identical error ratesBPSK and DPSKend;

figuresemilogx(ber,CtoDP);xlabel('bit error rate')

ylabel('Power Margin dB: DPSK-CBPSK')

Page 138: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 138/246

Page 138 of 246

figure

Problem 51 shannon.m

clear

%shannon.m%calculates the Shannon capacity theorem parameters

for k=1:64;rb(k)=0.5*k;

sn(k)=10*log10((2.^rb(k)-1)/rb(k));end;

semilogy(sn,rb);xlim([-5 42])

ylim([0.25 24])set(gca,'ytick',[0.25 0.5 1 2 4 8 16 24]);set(gca,'xtick',[-6 0 6 12 18 24 30 36 42 ]);

grid onxlabel('E/N_0 dB')ylabel('R/W b/s/Hz')

Page 139: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 139/246

Page 139 of 246

Values of power efficiency can be calculated from the expression for the BER (10-5).

Problem 52.

%BPSASKsim.m

clearclose all%BPSASKsim.m

%generates OOK and BPSK signals%adds noise

%coherent demodulation followed by LPF%OOK signal is also detected incoherently

close allfc=10e3;%carrier frequencyppf=2*pi*fc;

fs=12*fc;%sampling rateddt=1/fs;nn=1e-3/ddt;%total number of samples in one m sec

M=2^(nextpow2(nn))N=8;%number of bits

Page 140: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 140/246

Page 140 of 246

a=[1 1 -1 -1 -1 1 -1 1];%for BPSK

b=[1 1 0 0 0 1 0 1];%for ASKkp=floor(nn/8);%creates the width of the pulse

sd=input('enter the std dev.of additive white noise 0.01 to .7 ..');

for ku=1:8;for k=(ku-1)*kp+1:kp*kutt(k)=k*ddt;

s(k)=a(ku);%creates the pulse streamsa(k)=b(ku);%ASK datasf(k)=a(ku)*cos(ppf*tt(k))+normrnd(0,sd);%rf signal plus noise BPSK

sam(k)=b(ku)*cos(ppf*tt(k))+normrnd(0,sd);%rf signal plus noise ASK signalend;

end;plot(tt*1e3,s,tt*1e3,sf),title('data and BPSK signal')ylim([-4 4])

legend('Data','BPSK signal')figure

plot(tt*1e3,sa,tt*1e3,sam),title('data and OOK signal')ylim([-4 4])legend('Data','OOK signal')

for k=1:kp*8;sfd(k)=sf(k)*2*cos(ppf*tt(k));%coherent demodulation

samd(k)=sam(k)*2*cos(ppf*tt(k));%coherent demodulation OOK signalend;[bb,aa]=butter(5,.2);

sfd=filtfilt(bb,aa,sfd);samd=filtfilt(bb,aa,samd);

figureplot(tt*1e3,s,tt*1e3,sfd)legend('Data','BPSK demodulated data')

ylim([-4 4])figure

plot(tt*1e3,sa,tt*1e3,samd)ylim([-4 4])legend('Data','OOK demodulated data')

sq1=sam.^2;%square the OOK signal

ssq=sqrt(sq1);%gets the envelope by taking the square rootsq2=filtfilt(bb,aa,ssq);figure

plot(tt*1e3,sa,tt*1e3,sq2)ylim([-4 4])

legend('Data','OOK envelope detected data')

Page 141: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 141/246

Page 141 of 246

Page 142: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 142/246

Page 142 of 246

Problem 53. (See Problem 52)

Page 143: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 143/246

Page 143 of 246

Page 144: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 144/246

Page 144 of 246

Problem 54 see the m file for the previous exercise (BPSASKsim)

Page 145: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 145/246

Page 145 of 246

Problem 55. BPSKphasesim

clear%BPSKphasesim.m

%generates BPSK signalsadds noise coherent demodulation followed by LPF%examines the case of phase mismatch both fixed and random

close allfc=10e3;%carrier frequencyppf=2*pi*fc;

fs=12*fc;%sampling rateddt=1/fs;

nn=2e-3/ddt;%total number of samples in one m secM=2^(nextpow2(nn))

N=8;%number of bitsa=[1 1 -1 -1 -1 1 -1 1];%for BPSKkp=floor(nn/8);%creates the width of the pulse

sd=input('enter the std dev.of additive white noise 0.01-10 ..');for ku=1:N;for k=(ku-1)*kp+1:kp*ku

tt(k)=k*ddt;s(k)=a(ku);%creates the pulse stream

Page 146: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 146/246

Page 146 of 246

sf(k)=a(ku)*cos(ppf*tt(k))+normrnd(0,sd);%rf signal plus noise BPSK

end;end;

ph=input('enter the fixed phase mismatch in degrees...>>');phr=ph*pi/180;%conver to radians

phrandom=input('enter the mean phase mismatch for random phase error..>>');meanp=phrandom*pi/180;'a 10% standard deviation is assumed'

plot(tt*1e3,s,tt*1e3,sf),title('data and BPSK signal')ylim([-4 4])legend('Data','BPSK signal')

for k=1:kp*N;sd(k)=sf(k)*2*cos(ppf*tt(k));%coherent demodulation no mismatch

sdp(k)=sf(k)*2*cos(ppf*tt(k)+phr);% coherent demodulation fixed phase mismatchsdpr(k)=sf(k)*2*cos(ppf*tt(k)+normrnd(meanp,meanp*.1));%coherent demodulation random

phase mismatch

end;[bb,aa]=butter(5,.2);

sd=filtfilt(bb,aa,sd);sdp=filtfilt(bb,aa,sdp);sdpr=filtfilt(bb,aa,sdpr);

figureplot(tt*1e3,s,tt*1e3,sd,tt*1e3,sdp,tt*1e3,sdpr)

legend('Data','BPSK demodulated data','BPSK demodulated data-Fixed phase mismatch','BPSKdemodulated data-random phase mismatch')ylim([-4 4])

Page 147: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 147/246

Page 147 of 246

Problem 56. same as (Problem 52)

Problem 57 . BPSKdetect.m

%BPSKdetect.m

%generates BPSK signals adds noise coherent demodulation followed by LPF%examines the case of phase mismatch both fixed and random

%also detects the bitsclose allfc=10e3;%carrier frequency

ppf=2*pi*fc;fs=12*fc;%sampling rate

ddt=1/fs;nn=2e-3/ddt;%total number of samples in one m secM=2^(nextpow2(nn))

N=8;%number of bitsa=[1 1 -1 -1 -1 1 -1 1];%for BPSK

kp=floor(nn/8);%creates the width of the pulsesd=input('enter the std dev.of additive white noise 0.001-1 ');

Page 148: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 148/246

Page 148 of 246

for ku=1:N;

for k=(ku-1)*kp+1:kp*kutt(k)=k*ddt;

s(k)=a(ku);%creates the pulse streamsf(k)=a(ku)*cos(ppf*tt(k))+normrnd(0,sd);%rf signal plus noise BPSK

end;end;ph=input('enter the fixed phase mismatch in degrees...>>');

phr=ph*pi/180;%conver to radiansphrandom=input('enter the mean phase mismatch for random phase error..>>');meanp=phrandom*pi/180;

'a 10% standard deviation is assumed'sf=sf/abs(max(sf));

plot(tt*1e3,s,tt*1e3,sf),title('data and BPSK signal')ylim([-4 4])legend('Data','BPSK signal')

for k=1:kp*N;sdd(k)=sf(k)*2*cos(ppf*tt(k));%coherent demodulation no mismatch

sdp(k)=sf(k)*2*cos(ppf*tt(k)+phr);% coherent demodulation fixed phase mismatchsdpr(k)=sf(k)*2*cos(ppf*tt(k)+normrnd(meanp,meanp*.1));%coherent demodulation random

phase mismatch

end;[bb,aa]=butter(5,.2);

sdd=filtfilt(bb,aa,sdd);sdp=filtfilt(bb,aa,sdp);sdpr=filtfilt(bb,aa,sdpr);

figureplot(tt*1e3,s,tt*1e3,sdd,tt*1e3,sdp,tt*1e3,sdpr)

legend('Data','BPSK demodulated data','BPSK demodulated data-Fixed phase mismatch','BPSKdemodulated data-random phase mismatch')ylim([-4 4])

for kk=1:N

ky=kp/2+(kk-1)*kp;if sdd(ky)>0 %coh. demodulation noise only

b(kk)=1;

elseb(kk)=-1;

end;if sdp(ky)>0;%coh. demodulation noise plus fixed phase

c(kk)=1;

elsec(kk)=-1;

end;if sdpr(ky)>0;%coh. demodulation noise plus random phase

d(kk)=1;

Page 149: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 149/246

Page 149 of 246

else

d(kk)=-1;end;

end;

'input bit stream'a'output bit stream..coherent deomodulation'

b

'output bit stream coh. demodulation noise plus fixed phase'

c'output bit stream coh. demodulation noise plus random phase phase'

d

Problem 58. Same m file in exercise# 57Problem 59. Same m file in exercise# 58

Problem 60. qpqdemod.m

clear;%qpqdemod.m%creates a sequential way to generate QPSK waveforms and demodulates the QPSK

close allfc=10e3;%carrier frequency

ppf=2*pi*fc;fs=12*fc;%sampling rateddt=1/fs;

nn=2e-3/ddt;%total number of samples in one m secN=8;%number of bits

a=[1 1 -1 -1 -1 1 1 1];%for BPSKkp=floor(nn/8);%creates the width of the pulsesd=input('enter the std dev.of additive white noise 0.001-.1 ');

for jj=1:N/2;pp=2*jj-1;%creates the counter for the symbols

for kk=2*kp*(jj-1)+1:2*kp*jj;x(kk)=kk*ddt;

qpsk1(kk)=(a(pp)*cos(2*pi*fc*x(kk))+a(pp+1)*sin(2*pi*fc*x(kk)))/sqrt(2);

end;

end;

plot(x/(kp*ddt),qpsk1),title('QPSK')

Page 150: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 150/246

Page 150 of 246

for km=1:N*kp;%adds noise and demodulateskmt=km*ddt;

qpsnc(km)=(qpsk1(km)+normrnd(0,sd))*2*cos(2*pi*fc*kmt);qpsns(km)=(qpsk1(km)+normrnd(0,sd))*2*sin(2*pi*fc*kmt);

end;[bb,aa]=butter(10,.1);qpsnc=filtfilt(bb,aa,qpsnc);%low pass filtered

qpsns=filtfilt(bb,aa,qpsns);%low pass filteredmmu=0;for jy=1:N/2;

mmu=mmu+1;ky=kp+(jy-1)*2*kp;

if qpsnc(ky)>0b(mmu)=1;

else

b(mmu)=-1;end;

mmu=mmu+1if qpsns(ky)>0;

b(mmu)=1;

elseb(mmu)=-1;

end;end;'transmitted bits'

a

'received bits'b

Problem 61. DPSKdetect.m

clear%DPSKdetect.m%generates DPSK signals adds noise suboptimal demodulation followed by LPF

close allfc=12e3;%carrier frequency

ppf=2*pi*fc;fs=10*fc;%sampling rateddt=1/fs;

nn=2e-3/ddt;%total number of samples in one m secM=2^(nextpow2(nn))

N=8;%number of bitsa=[1 1 -1 -1 -1 1 -1 1];%for BPSKad(1)=1;%reference bit

Page 151: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 151/246

Page 151 of 246

for kf=2:N+1

ar=a(kf-1)*ad(kf-1);if ar==1;

ad(kf)=1;%DPSK bitelse

ad(kf)=-1;%DPSK bitend;end;

adkp=floor(nn/8);%creates the width of the pulsesd=input('enter the std dev.of additive white noise 0.001-10 ');

for ku=1:N+1;for k=(ku-1)*kp+1:kp*ku

tt(k)=k*ddt;if ku<=N

tt2(k)=k*ddt;

s(k)=a(ku);%input streamelse

end;sdd(k)=ad(ku);%creates the DPSK pulse streamsf(k)=ad(ku)*cos(ppf*tt(k))+normrnd(0,sd);%rf signal plus noise BPSK

end;end;

sf=sf/abs(max(sf));subplot(3,1,1)plot(tt2*1e3,s,'k')

xlim([ 0 2.5])ylim([-2 2])

legend('Data bits')subplot(3,1,2)plot(tt*1e3,sdd,'g')

ylim([-2 2])xlim([ 0 2.5])

legend('DPSK bits')subplot(3,1,3)plot(tt*1e3,sf,'r')

ylim([-2 2])xlim([ 0 2.5])

legend('DPSK signal')for k=1+kp:(N+1)*kp;

sfr(k-kp)=2*sf(k)*sf(k-kp);

end;[bb,aa]=butter(5,.2);

sfr=filtfilt(bb,aa,sfr);figurett1=tt(1:(N+1)*kp-kp);%to get the original length. This is also equal to tt2

Page 152: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 152/246

Page 152 of 246

subplot(2,1,1)

plot(tt2*1e3,s,'k')

ylim([-4 4])xlim([0 2.5])

legend('Data stream ')subplot(2,1,2)plot(tt2*1e3,sfr,'r')

legend('DPSK demodulated data')ylim([-4 4])xlim([0 2.5])

for kk=1:Nky=kp/2+(kk-1)*kp;

if sfr(ky)>0 %DPSK mod onlyb(kk)=1;

else

b(kk)=-1;end;

end;'input bit stream'a

'output bit stream..DPSK suboptimal'b

Page 153: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 153/246

Page 153 of 246

Problem 62. Use the same m file in exercise # 61.

Page 154: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 154/246

Page 154 of 246

Problem 63.

clear

%DPSKopt.m%generates DPSK signals adds noise optimal demodulation followed by LPF

%adds noiseclose allfc=12e3;%carrier frequency

ppf=2*pi*fc;fs=10*fc;%sampling rate

ddt=1/fs;nn=2e-3/ddt;%total number of samples in one m sec

M=2^(nextpow2(nn))N=8;%number of bitsa=[1 1 -1 -1 -1 1 -1 1];%for BPSK

ad(1)=1;%reference bitfor kf=2:N+1

ar=a(kf-1)*ad(kf-1);

if ar==1;ad(kf)=1;%DPSK bit

Page 155: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 155/246

Page 155 of 246

else

ad(kf)=-1;%DPSK bitend;

end;ad

kp=floor(nn/8);%creates the width of the pulsesd=input('enter the std dev.of additive white noise 0.001-0.01 ');for ku=1:N+1;

for k=(ku-1)*kp+1:kp*kutt(k)=k*ddt;if ku<=N

tt2(k)=k*ddt;s(k)=a(ku);%input stream

elseend;

sdd(k)=ad(ku);%creates the DPSK pulse stream

sf(k)=ad(ku)*cos(ppf*tt(k))+normrnd(0,sd);%rf signal plus noise BPSKend;

end;%sf=sf/abs(max(sf));subplot(3,1,1)

plot(tt2*1e3,s)legend('Data bits')

ylim([-2 2])xlim([0 2.5])subplot(3,1,2)

plot(tt*1e3,sdd)legend('DPSK bits')

ylim([-2 2])xlim([0 2.5])subplot(3,1,3)

plot(tt*1e3,sf/max(abs(sf)))ylim([-2 2])

xlim([0 2.5])legend('DPSK signal')for kk=1:(N+1)*kp;

sfc(kk)=2*sf(kk)*cos(ppf*tt(kk));sfs(kk)=2*sf(kk)*sin(ppf*tt(kk));

end;[bb,aa]=butter(10,.2);sfr=filtfilt(bb,aa,sfc);

sfi=filtfilt(bb,aa,sfs);for k=1+kp:(N+1)*kp;

x(k-kp)=sfr(k)*sfr(k-kp);y(k-kp)=sfi(k)*sfi(k-kp);

end;

Page 156: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 156/246

Page 156 of 246

xy=x+y;%

figurett1=tt(1:(N+1)*kp-kp);%to get the original length. This is also equal to tt2

subplot(2,1,1)plot(tt2*1e3,s)

ylim([-2 2])xlim([0 2.5])legend('Data stream ')

subplot(2,1,2)plot(tt2*1e3,xy)legend('DPSK optimal demodulated data')

ylim([-2 2])xlim([0 2.5])

for kk=1:Nky=kp/2+(kk-1)*kp;if xy(ky)>0

b(kk)=1;else

b(kk)=-1;end;

end;

'input bit stream'a

'output bit stream..DPSK optimal'b

Page 157: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 157/246

Page 157 of 246

Problem 64.

( ) ( )22

0

expu

erf u x dxπ

= −∫

( ) ( )22

0

exp 1erf x dxπ

∞ = − =∫

Therefore,

( ) ( ) ( ) ( ) ( ) ( )2 2 2 22 2 2 2

0 0 0

1 exp exp exp expu u

u

erf u x dx x dx x dx x dx erfc uπ π π π

∞ ∞

− = − = − − − = − =∫ ∫ ∫ ∫ .

Problem 65

( ) ( )22

0

expu

erf u x dxπ

= −∫ Let us put w = - u; We get,

( ) ( ) ( ) ( )2 22 2

0 0

exp expw w

erf w x dx x dx erf wπ π

− = − = − − = −∫ ∫ .

Page 158: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 158/246

Page 158 of 246

Problem 66

Filtered Noise

Problem 67. noise1

%noise1.mclear

close all%demonstrates.....the noise power after low pass filtering%Gaussian random variables are generated with different variances and filtered through the same

filterfor k=1:10; %10 different noise variances

beta(k)=0.25*k;%value of betax=normrnd(0,sqrt(beta(k)),1,4096);%generate 4096 samples of Gaussian random numbers..white noise

[a,b]=butter(5,.5);%Butterworth coefficients for LPFxx=filtfilt(a,b,x);%low pass filtered

pow(k)=var(xx);%filtered noise variance

Power Spectral Density Gn(f)

2

β

frequency0

frequency

-W W0

Power = area = W β

Page 159: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 159/246

Page 159 of 246

end;

plot(beta,pow,'*')xlabel('\beta')

ylabel('LP Filtered variance')

We can see a linear relationship between spectral density and output noise power (for a fixedLPF bandwidth).

The next section contains the effect of varying bandwidths on the output noise power for a fixedinput noise.

%noise2.m

clearclose all%demonstrates.....the noise power after low pass filtering%Gaussian random variables are generated a fixed variance and filtered through the different

LPFsfor k=1:8; %8 different LPF bandwidths

beta=2.1;%value of beta

Page 160: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 160/246

Page 160 of 246

x=normrnd(0,sqrt(beta),1,4096);%generate 4096 samples of Gaussian random numbers ..white

noiseff(k)=0.1*k;

[a,b]=butter(5,ff(k));%Butterworth coefficients for LPFxx=filtfilt(a,b,x);%low pass filtered for different LPF

pow(k)=var(xx);%filtered noise varianceend;plot(ff,pow,'*')

xlabel('normalized bandwidth')ylabel('LP Filtered variance')

We can see a linear relationship between spectral density and bandwidth (for a fixed noise

spectral density).

Problem 68. Let ( ) ( ) ( )1 0cos 2n t n t f t π= .

( ) ( ) ( ) ( ) ( ) ( )2 2 22

1 0 0

1cos 2 cos 2

2n t n t f t n t f t n t π π= = = .

Page 161: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 161/246

Page 161 of 246

Problem 69. %noise3.m

%shows that the variance of the noise is reduced by 1/2 after multiplication by cos(2*pi*fc*t)

clearclose all

k=1:4096;x=normrnd(0,1.3,1,4096);%generate 4096 samples of Gaussian random numbers ..white noisey=cos(2*pi*(1/100)*k);%cos(2*pi*fc*t)

xy=x.*y;ratio=var(x)/var(xy)

Problem 70 Let

( ) ( )0

0

cos 2T

out n n t f t dt π= ∫ is the output of the correlator.

The noise power is given by

( ) ( ) ( ) ( ) ( )

( ) ( ) ( ) ( )

2

0 0

0 0

0 0

0 0

cos 2 cos 2

cos 2 cos 2

T T

out

T T

n n t f t dt n f d

n n t f t f dtd

π τ π τ τ

τ π π τ τ

=

=

∫ ∫

∫ ∫

Because the noise is white,

( ) ( ) ( )

2

n t n t β

τ δ τ= − ,

the noise power becomes

( ) ( )2 2

0

0

cos 2 .2 2 2 2

T

out

T T n f t dt spec density

β βπ= = = ×∫ .

n(t)

cos(2πf 0t)

0

T

∫ nout

Page 162: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 162/246

Page 162 of 246

Thus, nout is a Gaussian random variable with zero mean and a variance of 2 2

T β.

Note: Result of exercise # 68 can be obtained by replacing the integration in exercise # 70 by

averaging, i.e.,0

T

∫ by0

1T

T T →∞ ∫ .

Problem 71. The narrowband noise n(t) is given by

( ) ( ) ( ) ( ) ( )cos 2 sin 2c c s cn t n t f t n t f t π π= − .

The spectral density of the noise Gn(f) is shown in figure.

The bandpass range is 2B. We must note that while n(t) is narrowband, ns(t) and nc(t) are low

pass components. Multiplying n(t) by ( )cos 2 c f t π and low pass filtering, we get

( ) ( ) ( )1

cos 22

c cn t f t n t π = .

Similarly, multiplying n(t) by ( )sin 2 c f t π and low filtering, we get

( ) ( ) ( )1

sin 2

2

c sn t f t n t π = .

The spectral densities of the inphase and quadrature components are obtained from

( ) ( ) ( )2 1

cos 22

c cn t f t n t π =

and

Gn(f)

-f c f c

2B 2B

2

β

0 frequency

Page 163: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 163/246

Page 163 of 246

( ) ( ) ( )2 1

sin 22

c sn t f t n t π = .

Using the results from exercise # 68, we have

( ) ( )

( ) ( )

2 2

2 2

1 1

2 4

1 1

2 4

c

s

n t n t

n t n t

=

=.

We can now write the expressions for the spectral densities of the inphase and quadrature

components, Gnc(f) and Gns(f), respectively as

( ) ( ) ( )

( ) ( ) ( )

2 2

2 2

2

2

nc c

ns s

G f n t n t

G f n t n t

β

β

= = =

= = =.

These spectral densities are shown in figure below.

The power of the narrowband noise n(t) is 2 2 22 2

B B Bβ β

β× + × = . The powers of the baseband

components, the inphase and quadrature, are equal. Each of them is equal to Bβ .

-B 0 Bfrequency

β

Gnc(f) or Gns(f)

Page 164: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 164/246

Page 164 of 246

Chapter 4

Problem 1Signal power = -100 dBm or 10-10 mW.

CCI Power=10-12.1 mW

Noise Power =10-11.9 mW

Overall signal-to-noise ratio =10

12.1 11.9

0

1016.6 12

6 6 10 10

S dB

CCI N

− −= = →× + × +

Signal-to-CCI ratio =10

12.1

1020.98 13.21

6 6 10

S dB

CCI

−= = →× ×

Problem 2Signal power = -97dBm or 10-9.7 mW.

CCI Power =10-12 mW

Noise Power =10-11.7 mW

Overall signal-to-noise ratio =9.7

12 11.7

0

1025 14

6 6 10 10

S dB

CCI N

− −= = →× + × +

Signal-to-CCI ratio =

9.7

1210 33.25 15.256 6 10

S dB

CCI

−= = →× ×

Required signal-to-CCI ratio =9.710

20 1006 s

dBP

→ =×

where Ps is the maximum CCI power

acceptable.

9.71310

3.325 10 124.78600

sP mW dBm−

−= = × → −

Problem 31

d d P

ν∝ ;

( ) 3

3.8

12 10

2P Km mW −= ∝

( )3.8

3 23 10 .214 36.7

3P Km W dBmµ

− = × = = −

Page 165: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 165/246

Page 165 of 246

( )3.8

3 526 10 1.5 10 48.1

6P Km mW dBm− − = × = × = −

Problem 4 Signal Power 44∝ ; CCI Power 410∝

Signal-to-CCI ratio =

4

10 39 15.94

dB = →

Problem 5 Signal-to-CCI ratio = 20 100dB →

3.2

1008

d =

;1

3.28 100 33.7d km= × =

Problem 6 Received Power (dBm) = Transmitted Power (dBm)-Loss(dB)= -105dBm

Transmitted Power =-105+115 =10 dBm → 10 mW.

Problem 7. Signal-to-CCI ratio =1

20 1006

DdB

R

ν

= →

;1

600 8.43 D

R

ν = =

.

Problem 8.signal-to-noise ratio 1.996 ( 115) 19 10dB= − − − = →

Threshold SNR 1.515 10dB →

Outage =

1.5

1.9

10

1 exp 0.328410

− − = .

Outage1.510

0.02 1 exp 1 expThresholdSNR

averageSNR averageSNR

= = − − = − −

1.5101565 31.2

log(0.98)averageSNR dB= − = →

Noise Power = average signal power- average SNR=-96-31.2=-127.2 dBm

Problem 9 See the relevant section

Problem 10Offered Load (From Table ) =13.188 Erl; Carried Load =13.188 x 0.98 = 12.98 Erl

Page 166: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 166/246

Page 166 of 246

Total carried traffic = 12.98x10=129.8 Erl.

Problem 11 Offered Traffic = 63.9; Carried Traffic = 63. 9x 0.98 =66.62 Erl

Consumption (Erl) by a single user = holding time(hour) x number of calls/hour

= (2/60) x 2 = 0.0667 ErlTotal Number of Users possible = Carried Traffic/traffic generated by a single user

= 66.62/.0667= 939.

Problem 12. Provider A

Offered Traffic/cell=13.188 Erl; Carried Traffic/cell=12.98 Erl

Total Carried Traffic =12.98*100= 1298 Erl

Traffic Generated by a single user = 2x(3/60)= 0.1 Erl.

Number of users that can be supported = 1298/0.1=12980.

Provider B

Offered Traffic/cell=43.99 Erl; Carried Traffic/cell=43.11 Erl

Total Carried Traffic =43.11 x 35 = 1508 Erl

Traffic Generated by a single user = 2x(3/60)= 0.1 Erl.

Number of users that can be supported = 1508/0.1=15080.

Problem 13. Traffic generated by a single user =3x(3/60)= 0.15 Erl

Carried Traffic = Number of users x Traffic generated by a single user =700 x 0.15 = 105 Erl

Offered Traffic = 105/.98=107.14 Erl

From the Tables, this corresponds to 120 channels.

Problem 14. use outlognorm.m from exercise #2-29.

Page 167: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 167/246

Page 167 of 246

Problem 15 . same as in (Problem 14).

Problem 16.raylsim.m

%raylsim%simulates Rayleigh random numbers and computes the outage

clearclose all

%envelope Rayleigh.......power is exponential%Pav=input('enter the average power in dBm...>>');P=10^(Pav/10);%power in mW

xe=exprnd(P,1,2000);%2000 random numbers, exponential with a mean corresponding to P dBmfor k=1:15;

x=Pav-k;%thrshold equal to the average power less than k

xp(k)=10^(x/10);%conversion to mW

xd(k)=k;%Difference between the thrshold and average powercount=0;

for kk=1:2000if xe(kk)<=xp(k)

Page 168: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 168/246

Page 168 of 246

count=count+1;

elseend;

endpouts(k)=count/2000;

end;%theoretical outagepthout=1-exp(-xp./P);

plot(xd,pouts,'g',xd,pthout,'r')legend('simulated outage','theoretical outage')ylabel('Outage Probability')

xlabel('Relative threshold (below the average power) dB')

Problem 17. same as in (Problem 16).

Problem 18

Power at the unsplit cell boundary tuP R ν−∝

Page 169: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 169/246

Page 169 of 246

Power at the cell boundary after splitting3

split

RP

ν− ∝

Pt u= 1W and ν =3. For identical performance, the powers at the cell boundaries must be

the same.

Thus,

3

3

3tu split

RP R P

−− =

.

3

1

3 27

tusplit

PP W = = .

Problem 19. The outage probability, Pout, under lognormal fading conditions is given by

1

2 2

av th p perfc

σ

where all the quantities in decibel units (Pav and Pth in dBm and σ in dB).

( )2 1 2 110th av out P P erfinv P dBmσ= − − = −

.

Problem 20. Long term fading margin =6 dB. If the loss is 0.7 dB/km, the margin

corresponds to a reduction in transmission distance of 6

0.7km or 8.5 km. Similarly, the short

term margin of 4 dB corresponds to a reduction in transmission distance of 4

0.7km or 5.7 km.

The total reduction will be 14.2 km.

Problem 21. poutagefringe.m

%poutagefringe.mclearclose all

%plots of equations in Chapter 4 for the calculation of the outage probability at the boundary%shows that the second term of the equation for the area outage probability is a mere correction(?)

sig=[4 6 8];%standard deviation of fadingloss=[2.5 3 3.5];% loss parameter

gamma=loss(1);for kk=1:3;

sigma=sig(kk)*log(10)/10;%conversion from dB to nepers (sse Lognormal dist)

sigma2=(sqrt(2)*sigma);for k=1:41;

M(k)=k;%fading margin in dBmk=10^(k/10);%margin converted to power unitsxx=log(mk)/sigma2;

outf(k)=0.5*erfc(xx);%outage at the fringeend;

semilogy(M,100*outf,'k')

Page 170: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 170/246

Page 170 of 246

xlabel('Fading Margin M dB')

ylabel('Outage Probability at the boundary %')ylim([.1 100])

hold onend;

Problem 22.poutagearea.m

%poutagearea.m

clearclose all

%plots of equations in Chapter 4 for the calculation of the area outage probabilitysig=[4 6 8];%standard deviation of fading

loss=[2.5 3 3.5];% loss parametergamma=loss(1);for kk=1:3;

sigma=sig(kk)*log(10)/10;%conversion from dB to nepers (sse Lognormal dist)sigma2=(sqrt(2)*sigma);

for k=1:41;

M(k)=k;%fading margin in dBmk=10^(k/10);%margin converted to power units

Page 171: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 171/246

Page 171 of 246

xx=log(mk)/sigma2;

outf(k)=0.5*erfc(xx);%outage at the fringeyy=sigma2/gamma;

outar(k)=outf(k)-0.5*erfc(xx+yy)*exp(2*xx*yy+yy^2);end;

semilogy(M,100*outar,'b')xlabel('Fading Margin M dB')ylabel('Outage Probability (area) %')

ylim([.1 100])hold onend;

Problem 23. The probability of outage is ( )2

1

2 2out

mP R erfc

σ

=

where the power margin

M (dB) is expressed as10

10log M m= . We have ( )1 1

log 10 2.30 6 1.3810 10

e dBσ σ= = × × = .

Outage =01.;

Using the relationship between erfc and erf functions, we can write

[ ]22 1.38 1 2 .01 3.2m erfinv= × − × = ; ( )10

10 log 5 M m dB= × =Outage =05.;

Page 172: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 172/246

Page 172 of 246

[ ]22 1.38 1 2 .05 2.27m erfinv= × − × = ( )10

10 log 3.6 M m dB= × =

Power at a distance of 4 Km is 510 mW − . Threshold power is –91 dBm. Including the margin,

we have minimum required power =-91+5=-86 dBm 8.610 mW −→ (outage of 0.01), and –

91+3.6=-87.4 dBm8.74

10 mW −

→ .

3.5

5

3.5

8.6

1

3.5

8.74

2

110

4

110

110

d

d

.

1 242 ; 46d km d km= = .

Problem 24.

Omni-directional antenna

Number of Channels/Sector = 54Offered Traffic at a GOS of 2% = 43.4 Erl

Carried Traffic = 43.4 x 0.98 = 42.53 Erl

Trunking Efficiency =42.53

% 78.7%54

=

120o Sector antenna

Number of Channels/sector =54/3 = 18Offered Traffic at a GOS of 2% = 11.5ErlCarried Traffic = 11.5 x 0.98 = 11.27 Erl

Total Carried Traffic= 11.27x3 = 33.81 Erl

Trunking Efficiency =33.81

% 62.6%54

=

60o Sector antenna

Number of Channels/sector =54/6 = 9Offered Traffic at a GOS of 2% = 4.35ErlCarried Traffic = 4.35 x 0.98 = 4.26 Erl

Total Carried Traffic= 4.26x6 = 25.6 Erl

Page 173: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 173/246

Page 173 of 246

Trunking Efficiency =25.6

% 47.41%54

= .

Problem 25. signal-to-noise ratio=9

12 11

1062.5 18

6 10 10dB

− − = →× +

.

Problem 26. Let the desired signal power (average) be Pavs Watts. Let the co-channel power

(average) at the MU be Pavc Watts.

We have10

10log avs

avc

P

=

. The probability density function of the desired signal power, Ps,

will be

( )1

exp s

s

avs avs

p f p

P P

= −

and the pdf of the co-channel power, Pc, will be

( )1

exp c

c

avc avc

p f p

P P

= −

.

Outage occurs when the co-channel power exceeds the desired signal power.

Outage probability = c sProb P P> .

Assuming that the two powers are independent, this outage probability is given by the shaded

area below.

( ) ( )0 0

1

1

s p

avcout s c c s

avsavc avs

avc

PP f p f p dp dp

PP P

P

∞ = = =

+ +∫ ∫ .

pc

ps

Ps >Pc

Ps <Pc

Page 174: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 174/246

Page 174 of 246

10

1

1 10

out P

α

=

+

Problem 27. outprotectionRayl.m

%outprotectionRayl

clearclose all%computes the outage as a function of the protection ratio, i.e. ratio of the

%desired signal power to CCI power%Rayleigh fading

alpha=[0:2:40];%protection in dB

alp=10.^(alpha/10);outage=1./(1+alp);semilogy(alpha,outage,'k'),title(' Rayleigh faded signal and Rayleigh faded CCI')

xlabel('Protection ratio \alpha dB')ylabel('Outage probability')

Page 175: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 175/246

Page 175 of 246

Figure P 4-27

Problem 28. Let us assume that mean desired power be P0 dBm and the mean CCI power be

Pd dBm. WE have [ ]0 d P P dBα = − .

We have (if we designate Y as the desired signal power and X as the CC power in dBm)

( )

( )2

22

1

exp 22

d x P

f x σπσ

= − and

( )( )

2

0

22

1exp

22

y P f y

σπσ

−= −

.

Page 176: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 176/246

Page 176 of 246

Outage occurs when X Y ≥ or when 0 X Y − ≥ .

We solve this problem easily by finding out the density function of Z X Y = − . Knowing that

both X and Y are Gaussian and independent random variables, Z will also be a Gaussian random

variable with a variance equal to the sum of the variances ( )2

2σ and mean equal to the

difference of the means ( )α− . The density function of Z is given by

( )( )

2

22

1exp

22 z z

z f z

α

σπσ

+= −

where 2 22 zσ σ= .

The outage occurs when 0 Z ≥ and thus, the outage probability is given by

( )2

220

1 1 1exp

2 2 2 222out

z z z

zP dz erfc erfc

α α α

σ σσπσ

∞ + = − = =

∫ .

Problem 29. outprotectionlogn.m

%outprotectionlogn

clear

close all%computes the outage as a function of the protection ratio, i.e. ratio of the

%desired signal power to CCI power when lognormal fading is present

alpha=[0:2:40];%protection in dB

sigma=[4 6 8 10];for k=1:4

sig=sigma(k);sig2=2*sig;

outage=0.5*erfc(alpha/sig2);semilogy(alpha,outage,'k')

hold on

end;

title(' Lognormal faded signal and Lognormal faded CCI')xlabel('Protection ratio \alpha dB')

ylabel('Outage probability')

Page 177: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 177/246

Page 177 of 246

ylim([0.000001 .5])

Problem 30. Raylrandomoutage.m

%Raylrandomoutage%generates exponentially distributed random variables with powers (desired and CCI)%to obtain outage under the conditions that both desired signal and CCI signal are Rayleigh

faded.

clear

close allN=5000;% random numbers

for k=1:21alpha(k)=k-1;

alp=10^(alpha(k)/10);x=exprnd(1,1,N);y=exprnd(1/alp,1,N);

count=0;

Page 178: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 178/246

Page 178 of 246

for kk=1:N

if y(kk)>=x(kk);count=count+1;

elseend;

end;outage(k)= count/N;end;

semilogy(alpha,outage),title(' Rayleigh faded signal and Rayleigh faded CCI..random numbers')

xlabel('Protection ratio \alpha dB')ylabel('Outage probability')

Problem 31. lognrandomoutage.m

%lognrandomoutage%generates exponentially distributed random variables with powers (desired and CCI)

Page 179: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 179/246

Page 179 of 246

%to obtain outage under the conditions that both desired signal and CCI signal are lognormal

faded.

clearclose all

N=6000;% random numbersfor ks=1:5sigma=2*ks;%standard deviation of fading

for k=1:16alpha(k)=k-1;x=normrnd(alpha(k),sigma,1,N);%average power equal to the difference in powers (signal)

y=normrnd(0,sigma,1,N);%average power equal zero ....CCIcount=0;

for kk=1:Nif y(kk)>=x(kk);

count=count+1;

elseend;

end;outage(k)= count/N;end;

semilogy(alpha,outage,'k')hold on

end;xlabel('Protection ratio \alpha dB')ylabel('Outage probability')

title(' Lognormal faded signal and lognormal faded CCI..random numbers')ylim([0.001 0.5])

Page 180: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 180/246

Page 180 of 246

Figure P. 4-31

Page 181: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 181/246

Page 181 of 246

Chapter 5

Problem 1. The density function of the signal-to-noise ratio in the absence of any diversity is

given by0 0

1exp

γ

γ γ

where γ is the signal-to-noise ratio and

0γ is the average signal-to-noise

ratio. We are given that is 3 dB or 2. The threshold SNR is 0 dB or 1. The outage probability in

the absence of any fading is1

0

1 1 1exp 1 exp 0.2835

3 3 3d γ γ

− = − − = ∫ . When diversity is used,

the density function of the SNR is given by( ) 0 0

1 1exp

1 ! M

M

M

γ γ

γ γ

−− −

. The outage probability

is given by

1 5

66

0

1 5087 1exp 1- exp - 1.4 10120 3 3 3645 3

d γ γ γ − − = = × ∫ . (Note: You may use gamcdf

from the Statistics Toolbox to get the integral or use the Symbolic Toolbox to evaluate theintegral).

Problem 2. The density function of the signal-to-noise ratio in the absence of any diversity is

given by0 0

1exp

γ

γ γ

where γ is the signal-to-noise ratio and

0γ is the average signal-to-noise

ratio. We are given that is 3 dB or 2. The threshold SNR is 0 dB or 1. The outage probability in

the absence of any fading is1

0

1 1 1exp 1 exp 0.2835

3 3 3d γ γ

− = − − = ∫ . When diversity is used,

the density function of the SNR is given by

5

0 0 0

1 exp exp M γ γ

γ γ γ

− − −

. The outage

probability is given by

5 61

4

0

12 1 exp exp 1 exp 5.8 10

3 3 3d

γ γ γ − − − − = − − = ×

∫ . (Note:

You may use the Symbolic Toolbox to evaluate the integral).

Problem 3.Consider the case of a Rayleigh distributed envelope with a pdf given by

( ) ( )2

2 2exp

2

x x f x U x

b b

= −

where ( )2 22 E X b= (Average Power). If we set a threshold envelope value of xT , the probability

that the detected envelope will be less than this threshold (i.e., outage probability) is given by

Page 182: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 182/246

Page 182 of 246

2 2

2 2 2

0

exp 1 exp2 2

T x

T x x x

dxb b b

− = − −

∫ .

The probability that all the M channels (diversity envelopes) will have their respective envelopes

to be less than T x will be

2

21 exp

2

M

T x

b

− −

.

The probability that at least one channel would have an envelope that will be greater than thethreshold will be

2

21 1 exp 2

M

T x

b

− − − The probability density function of the selection combiner using envelopes is obtained as

( )

12 2 2

2 2 2 21 1 exp 1 exp exp

2 2 2

M M

T T T T T

T

d x x x x M U x

dx b b b b

− − − − = − − −

.

Replacing T x with x, we can now write the general expression for the pdf of the selection

combiner of envelopes as

( ) ( )

12 2

2 2 21 exp exp

2 2

M

M

x x x f x M U x

b b b

− = − − −

.

If we put M =1, we have no diversity, the expression above becomes a Rayleigh density

function.

Problem 4 Raylseldiv.m

%Raylseldiv.m

clearclose all

%generates the pdf of selection diversity when envelopes are consideredb=1;M1=[1 3 6];

x=0:0.01:5;for k=1:3

M=M1(k);

Page 183: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 183/246

Page 183 of 246

ex1=exp(-x.^2/2);

ex2=(1-ex1).^(M-1);y=M*x.*ex1.*ex2;

plot(x,y,'r');hold on

end;xlabel('Envelope')ylabel('pdf')

Problem 5. The density function of the election combiner may be derived using order

statistics. Let X1, X2, ..Xk be k independent identically distributed random variables. We are

seeking the density function of the random variable 1 2max , , k Z X X X = L where Z is the

output of the selection combiner.

Let us assume that X1 is the largest of the set. This means that the rest of the random numbers

must be less than z. Thus, the probability that X1 lies between z and z+dz will be given by

( ) ( )1 1 3Pr Pr , , z X z dz X z X z≤ ≤ + ≤ ≤ L .

Page 184: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 184/246

Page 184 of 246

This probability is also equal to ( ) f z dz . In other words,

( ) ( ) ( ) ( ) ( )11 1 3

2

Pr Pr , ,n

k

x x

n

f z dz z X z dz X z X z f z dz F z=

= ≤ ≤ + ≤ ≤ = ∏L

We could have chosen any other variable as the largest one in place of X1. The CDF is indicated

by F. Since all such possibilities are mutually exclusive, the density function f(z) of themaximum is given by

( ) ( ) ( )1

m n

k k

x x

m n m

f z f z F z= ≠

= ∑ ∏ .

Because all the random variables are identically distributed, the density function becomes

( ) ( ) ( ) 1k x x f z kf z F z −= .

Problem 6. simpleselection.m

%simpleselection.m%conducts a selection diversity using Rayleigh random numbers

clearclose all

N=1000;x1=raylrnd(1,1,N);x2=raylrnd(1,1,N);

x3=raylrnd(1,1,N);x4=raylrnd(1,1,N);x5=raylrnd(1,1,N);

x6=raylrnd(1,1,N);x7=raylrnd(1,1,N);

x8=raylrnd(1,1,N);x9=raylrnd(1,1,N);x10=raylrnd(1,1,N);

xsel=max(max(max(max(max(max(max(max(max(x1,x2),x3),x4),x5),x6),x7),x8),x9),x10);n=1:N;

plot(n(1:10),x1(1:10),'g*',n(1:10),x2(1:10),'k+',n(1:10),xsel(1:10),'rd')ratio1=mean(x1)/std(x1)ratiosel=mean(xsel)/std(xsel)

xlabel('sample number')ylabel('sample values')

legend('any one set','another set','largest of the ten sets')

Page 185: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 185/246

Page 185 of 246

( )

( )

1.9012.

4.76 10.

Mean Nodiversity

Std Dev

MeanSelectiondiversityof

Std Dev

=

=

Only 10 samples are shown.

Problem 7. berpsk.m

clear%berpsk.m

%caculates the ber fo CBPSK, DPSK, and Coherent GMSK for fading and no fading usinganalytical means.for b=1:1:50;

% sn is the signal to noise ratio in DBs;sn(b)=b;

snr(b)=10.0^(b/10);xx=erfc(sqrt(snr(b)));bpsk(b)=0.5*xx;%BPSK no fading

Page 186: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 186/246

Page 186 of 246

denmr=sqrt(1.0+1.0/snr(b));

bpskf(b)=0.5*(1-1.0/denmr);% BPSK fading;dpsk(b)=0.5*exp(-snr(b));%DPSK no fading

dpskf(b)=0.5*1/(1+snr(b));%DPSK fadingfactor=sqrt(0.89*snr(b));

factor2=sqrt(1+0.89*snr(b));gmsk(b)=erfc(factor);%GMSK no fading; factor =0.89 for BT=0.3gmskf(b)=0.5*(1-factor/factor2);%GMSK fading

end;figure (1)semilogy(sn,bpsk,'r',sn,bpskf,'k'); %y axis is log;

legend('BPSK--Gaussian Channel','BPSK--Rayleigh Channel')axis([1.0 50.0 .00001 0.1]);

xlabel('signal-to-noise ratio dB')ylabel('probability of error')

figure (2)

semilogy(sn,dpsk,'r',sn,dpskf,'k'); %y axis is log;legend('DPSK--Gaussian Channel','DPSK--Rayleigh Channel')axis([1.0 50.0 .00001 0.1]);

xlabel('signal-to-noise ratio dB')ylabel('probability of error')

figure (3)

semilogy(sn,gmsk,'r',sn,gmskf,'k'); %y axis is log;legend('GMSK--Gaussian Channel','GMSK--Rayleigh Channel')

axis([1.0 50.0 .00001 0.1]);xlabel('signal-to-noise ratio dB')ylabel('probability of error')

Page 187: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 187/246

Page 187 of 246

Problem 8. The density function of the scaling factor is uniform. The bit error rate for BPSK

is given by ( )1

2erfc z where Z is the SNR. The probability of error when the scaling factor is

random is given by 21

2erfc a z where the pdf of a is given by

( ) 0.5; 0 2 f a a= ≤ ≤ .

The average probability of error when the scaling factor is present is given by

( ) ( )

2 2

2 2

0 0

1 1 1

2 2 4erfc a z da erfc a z da=∫ ∫ This integral has been evaluated numerically.

%pskpuniformfading.mclear

close all

Page 188: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 188/246

Page 188 of 246

%computes the error rate uniform fading :exercise 4-6

for k=2:50;global snr

sn(k)=k;%signal-to-noise raio in dBsnr=10.^(k/10);

aa=quadl('funerr',0,2);%numerical integrationber(k)=0.5*erfc(sqrt(snr));berf(k)=aa;

end;semilogy(sn,ber,'g',sn,berf,'r');ylim([1e-6 0.1])

legend('no fading','fading-uniform density')xlabel('signal-to-noise ratio dB')

funerr.m

function y=funerr(xx)global snr

%for pskuniformfadingy=0.25*erfc(sqrt(snr*xx.^2));

Page 189: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 189/246

Page 189 of 246

The error rates come down very slowly as the signal-to-noise ratio increases. This means that a

high power margin may be required to compensate for the fading.

Problem 9. The density function of the phase, ( ) ( )9

,2 9 9

f rad π π

φ φπ

= − ≤ ≤ . The probability

of error when the phase mismatch is uniform is given by ( )18

18

9 1cos

2 2erfc z d

π

π

φ φπ

∫ .

%pskpuniphase.mclearclose all

%computes the error rate uniform fadingfor k=2:50;

global snrsn(k)=k;%signal-to-noise raio in dBsnr=10.^(k/10);

aa=quadl('funpha',-pi/9,pi/9);%numerical integrationber(k)=0.5*erfc(sqrt(snr));

berf(k)=aa;end;semilogy(sn,ber,'g',sn,berf,'k');

ylim([1e-6 0.1])

xlim([2 15])legend('no fading','uniform phase')

xlabel('signal-to-noise ratio dB')ylabel('Probability of error')

funpha.m

function y=funpha(xx)

global snr%for pskuniphase

y=(9/(2*pi))*0.5*erfc(sqrt(snr)*cos(xx));

Page 190: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 190/246

Page 190 of 246

The probability of error in presence of fading is only slightly worse than the probability error in

the absence of fading.

Problem 10. The Rician pdf is given by2 2

0 0

02 2 2exp

2

a A aAa I

b b b

+ −

with K(dB) given by

( ) ( )1010logK dB k = where

2

0

22

Ak

b= The pdf ( ) Rice f z of the power (or the signal-to-noise

ratio) of the power (or SNR) Z =A2 is given by

( )( )

( )[ ]

[ ]0

0 0 0

11exp exp 4 1 Rice

z k k z f z k I K k

z z z

++= − − +

where

[ ]2 2 2 20 02 2 1 z averagepower a z b A b k = = = = + = +

Note that when 0k → , the pdf of the SNR becomes0 0

1exp

z

z z

as we have seen in the case

of Rayleigh fading.

Page 191: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 191/246

Page 191 of 246

The average error probability is given by ( )0

1

2Rice

erfc z f z dz∞

∫ .

The integration to obtain the average probability of error can be done numerically using

trapezoidal rule.

%ricianerror1.m

%calculates the error probability in Rician fading for BPSK%uses trapz to calculate the integral

clear allclose allKD=[-25 -10 0 5 10 15];%K factor in dB

for m=1:6kdb=10^(KD(m)/10);

k1=kdb+1;for k=4:50;

snr(k)=k+1;%snr in dBsn=10^(snr(k)/10);x=0:pi/500:0.99*pi/2;%converts the integral from 0-inf to 0-pi/2

x1=tan(x);x2=x1.^2;er=0.5*erfc(sqrt(x1));

ex=exp(-x1*k1/sn);exi=besseli(0,sqrt(4*kdb*k1*x1/sn));xxs=1+x2;%sec^2

y=ex.*er.*exi.*xxs;zz=trapz(x,y);

z(k)=exp(-kdb)*zz*k1/sn;%error rate in fading%%%%%% uses trapz to compute the integralyy(k)=0.5*erfc(sqrt(sn));%no fadingend;

semilogy(snr,z,'r',snr,yy,'g')ylim([0.0000001 .5])

xlim([5 25])hold onend;

Page 192: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 192/246

Page 192 of 246

It is seen that as the Rician parameter increases in value, the error probability approaches that of the no fading or Gaussian channel case. The higher values of the direct component mitigates the

variation in the signal components from the multipaths, reducing the effects of fading. We canalso come to the same conclusion by looking at the results from Chapter 2 where it is argued thatthe channel becomes Gaussian as the K value increases.

Problem 11. The average error probability is given by ( ) ( )0

1exp

2Rice z f z dz

−∫ .

The integration to obtain the average probability of error can be done numerically using

trapezoidal rule.

%ricianerrordpsk.m

%calculates the error probability in Rician fading for DPSK%uses trapz to calculate the integral

clear allclose allKD=[-25 -10 0 5 10 15];%K factor in dB

for m=1:6

Page 193: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 193/246

Page 193 of 246

kdb=10^(KD(m)/10);

k1=kdb+1;for k=4:50;

snr(k)=k+1;%snr in dBsn=10^(snr(k)/10);

x=0:pi/500:0.99*pi/2;%converts the integral from 0-inf to 0-pi/2x1=tan(x);x2=x1.^2;

er=0.5*exp(-x1);ex=exp(-x1*k1/sn);exi=besseli(0,sqrt(4*kdb*k1*x1/sn));

xxs=1+x2;%sec^2y=ex.*er.*exi.*xxs;

zz=trapz(x,y);z(k)=exp(-kdb)*zz*k1/sn;%error rate in fading%%%%%% uses trapz to compute the integralyy(k)=0.5*exp(-sn);%no fading

end;semilogy(snr,z,'r')

ylim([0.0000001 .5])xlim([5 30])hold on

end;semilogy(snr,yy,'g')

xlabel('SNR dB')ylabel('Probability of error')

Page 194: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 194/246

Page 194 of 246

Problem 12. The first step in the diversity calculations is the derivation of the pdf of the

selection combiner. Using results of exercise # 5, we can write the expression for the pdf of theselection combiner as

( ) ( ) ( )1

1 1,0 2

2 2

M M

div

a f a Mf a F a M a

−− = = ≤ ≤

.

(Verify that this is a valid density function).

The average error probability is given by

( ) ( ) ( )12 2

2 2

0 0

1 1 1

2 2 2 2

M

div

aerfc a z f a da M erfc a z da

− = ∫ ∫ .

The average error probability is plotted for M=2, 4, 6.

pskuniformdiv.m

Page 195: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 195/246

Page 195 of 246

%pskuniformdiv.m

clearclose all

%computes the error rate uniform fading with diversityexercise 4-6global M

mn=[1 2 4 8];for mm=1:4M=mn(mm);

mfact=(M/2)*(1/2)^(M-1);for k=1:16;

global snr

sn(k)=k+4;%signal-to-noise raio in dBsnr=10.^(sn(k)/10);

aa=quadl('funerrdiv',0,2);%numerical integrationberf(k)=(M/2)*aa;

end;

semilogy(sn,berf);ylim([1e-6 0.1])

xlabel('signal-to-noise ratio dB')ylabel('Probability of error')hold on

end;ssn=10.^(sn/10);

ber=0.5*erfc(sqrt(ssn));semilogy(sn,ber,'g');

funerr.m

function y=funerr(xx)global snr%for pskuniformfading

y=0.25*erfc(sqrt(snr*xx.^2));

Page 196: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 196/246

Page 196 of 246

Problem 13. The average error probability will be given by ( )21

2erfc a z f a da∫ .

Using the given density function, the average error probability is

( ) ( ) ( )2

0

10.1 0.5 1 0.4 2

2erfc za a a a daδ δ δ

+ − + − ∫ .

This can be simplified to

0.1 1 1 0.1 1(0) 0.5 0.4 4 0.2 4

2 2 2 2 4erfc erfc z erfc z erfc z erfc z× + × × + × × = + + × .

pskdeltafad.m

clear

close all%pskdeltafad.m

%computes the average error probability for the exercise where the fading has a discrete densityfunction

Page 197: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 197/246

Page 197 of 246

ssn=2:1:20;%snr in dB

sn=10.^(ssn/10);ber=0.5*erfc(sqrt(sn));%no fading

berf=(1/20)*erfc(0)+0.25*erfc(sqrt(sn))+.2*erfc(sqrt(4*sn));%fadingberfd=(0.01/2)*erfc(0)+(0.35/2)*erfc(sqrt(sn))+(.64/2)*erfc(sqrt(4*sn));%fading after selection

diversity M=2berfeq=(0.01/2)*erfc(0)+(0.1/2)*erfc(sqrt(sn))+(.33/2)*erfc(sqrt(4*sn))+(.4/2)*erfc(sqrt(9*sn))+(.16/2)*erfc(sqrt(16*sn)); %equal gain M=2

semilogy(ssn,ber,'r',ssn,berf,'g',ssn,berfd,'k',ssn,berfeq,'b')xlabel('signal-to-noise ratio dB')ylabel('Average error probability')

ylim([0.0000001 .5])xlim([5 20])

It is seen that error floor exists and it is equal to 0.05.

Problem 14. The first step in this exercise is to determine the pdf of the selection diversity

output. We have two independent identically distributed random variables, each having a pdf of

Page 198: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 198/246

Page 198 of 246

( ) ( ) ( ) ( )0.1 0.5 1 0.4 2 , 1,2. j j j j f a a a a jδ δ δ = + − + − =

The selection diversity output will be 1 2max ,a a a= . This probability may be obtained as

follows:

outcome prob.

0 0.1

a1 1 0.5

2 0.4

outcome prob.

0 0.1

a2 1 0.5

2 0.4

Outcomes of choosing the largest

a1 a2 Largest Prob of this event Prob of this outcome

0 0 0 0.1*0.1 0.1*0.1=0.01

0 1 1 .1*.5

1 0 1 .1*.5 2(.1*.5)+.5*.5=0.35

1 1 1 .5*.5

0 2 2 0.1*0.4

2 0 2 0.1*0.4

1 2 2 0.5*0.4 2(0.1*0.4+.5*.4)+0.4*0.4=0.642 1 2 0.5*0.4

2 2 2 0.4*0.4

Thus, the pdf of the selection diversity is given by

( ) ( ) ( ) ( )0.01 0.35 1 0.64 2sel f a a a aδ δ δ= + − + − .

The average error probability after selection diversity is given by

( ) ( ) ( ) ( )2

0

1 .01 0.35 0.640.01 0.35 1 0.64 2 0 4

2 2 2 2erfc a z a a a da erfc erfc z erfc zδ δ δ

+ − + − = + + ∫ .

See the m file and figure in the solution to exercise # 13.

Page 199: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 199/246

Page 199 of 246

Problem 15. The equal gain diversity is a simple addition of the two outcomes: The pdf of

the equal gain diversity is given by

( ) ( ) ( ) ( ) ( ) ( )0.01 0.1 1 0.33 2 0.4 3 .16 4eq f a a a a a aδ δ δ δ δ= + − + − + − + − .

The average error probability through the use of an equal gain diversity system is

( ) ( ) ( ) ( ) ( )

( )

2

0

10.01 0.1 1 0.33 2 0.4 3 .16 4

2

.01 0.1 0.33 0.4 0.160 4 9 16

2 2 2 2 2

erfc a z a a a a a da

erfc erfc z erfc z erfc z erfc z

δ δ δ δ δ∞

+ − + − + − + −

= + + + +

∫ .

Note that the improvement over the selection diversity occurs at low values of the SNR. As SNRgoes to infinity, the error floor for the selection and equal gain diversity becomes 0.005.

See the m file and figure in the solution to exercise # 13.

Problem 16. The error probability in Gaussian channels for DPSK format is given by

( )1

exp2

z− where z is the signal-to-noise ratio. When fading is present, the signal-to-noise ratio

becomes a random variable. Nakagami fading is a general fading model which can encompass

both Rayleigh and Rician fading. The pdf of the Nakagami distributed envelope is given by

( )

2 1

22 exp

m mm a m

am

− − Ω Γ Ω .

Once again defining Z=A2, the pdf ( ) N f z of the Nakagami distributed signal-to-noise ratio is

given by

( )

( )

1

0 0

exp

mm

N

m z m f z z

z m z

− = −

Γ

where z0 is the average signal-to-noise ratio given by 2

0 z a z= Ω = = .

When m=1, we have Rayleigh statistics and when m>1 we have Rician statistics. When m → ∞ ,

we approach the ideal Gaussian channel.

Page 200: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 200/246

Page 200 of 246

The average error probability (for DPSK) in Nakagami fading is given by

( ) ( ) ( )( )

1

0 00 0

1 1exp exp exp

2 2

mm

N

m z m z f z dz z z dz

z m z

∞ ∞ − − = − − Γ

∫ ∫ .

This can be easily integrated to0

1

2

m

m

m z

+

.

nakadpsk.m

%nakadpsk.m

%computation of BER in presence of Nakagami fadingclose all

clearm=[1 1.5 2 5 10 50];%m=1 corresponds to Rayleighfor km=1:6;

naka=m(km);%m-valuefor k=4:30;

sn(k)=k;ss=10^(k/10);%snrpe(k)=0.5*(naka/(naka+ss))^naka;

end;semilogy(sn,pe);

xlabel('signal-to-noise ratio dB')ylabel('Average error probability')ylim([0.0000001 0.5])

xlim([5 30])hold on

end;

sf=10.^(sn/10);

dpske=0.5*exp(-sf);%no fadingsemilogy(sn,dpske,'r');

Page 201: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 201/246

Page 201 of 246

It seen that as m increases, the error probability approaches that of Gaussian channel. The resultsare similar to those seen with Rician fading. Large values of K correspond to high values of m.

Problem 17. nakabpsk.m

%nakabpsk.m%computation of BER in presence of Nakagami fading

close allclearm=[1 1.5 2 5 10 50];%m=1 corresponds to Rayleigh

for km=1:6;naka=m(km);%m-value

for k=4:30;

sn(k)=k;ss=10^(k/10);%snr

mz=(naka/ss)^naka;gm=gamma(naka);

x=0:pi/500:0.99*pi/2;%converts the integral from 0-inf to 0-pi/2x1=tan(x);x2=x1.^2;

xxs=1+x2;%sec^2

Page 202: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 202/246

Page 202 of 246

er=0.5*erfc(sqrt(x1));

ex1=exp(-naka*x1/ss);xm=x1.^(naka-1);

y=ex1.*xm.*er.*xxs;zz=trapz(x,y);

pe(k)=zz*mz/gm;end;semilogy(sn,pe);

xlabel('signal-to-noise ratio dB')ylabel('Average error probability')ylim([0.0000001 0.5])

xlim([5 30])hold on

end;

sf=10.^(sn/10);

bpske=0.5*erfc(sqrt(sf));%no fadingsemilogy(sn,bpske,'r');

Page 203: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 203/246

Page 203 of 246

Problem 18.The average error probability for the case of BPSK in presence of Rayleigh

fading can be expressed as0 00

1 1exp

2

zerfc z dz

z z

∞ −

∫ where we have used the exponentially

distributed signal-to-noise ratio (when the envelope is Rayleigh distributed). The average signal-

to-noise ratio is given by z0.

Equation above can be integrated (by parts) leading to

( ) ( )0 000

1 1exp exp

2 2

z z d erfc z erfc z dz

z z dz

∞∞ − − + − ∫

( )00

11 exp

2

z d erfc z dz

z dz

∞ = + − ∫

where we have made use of the fact that erfc(0)=1.

( ) ( )22 1

exp x

z

d d erfc z e dx z

dz dz zπ π

∞−

= = − −

∫ .

This result has been obtained using Leibniz’s rule (See the end of this section).

The average error probability now becomes

( )0 00 0

1 1 1 1 11 exp exp 1 exp2 2

z z z dz z dz z z z zπ π

∞ ∞

− − − = − − − ∫ ∫

This readily integrates to

0

1 11

2 11

z

+

.

Problem 19. The average probability of error for DPSK in Rayleigh fading is given by

( )0 00

1 1exp exp

2

z z dz

z z

∞ − −

∫ .

This can be simplified to

Page 204: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 204/246

Page 204 of 246

( )0 0 00

1 1 1 1exp 1

2 2 1 z dz

z z z

∞ − + = +

∫ .

Problem 20.

%simpleselectionexp.m%conducts a selection diversity using exponential random numbers

clearclose all

N=1000;x1=exprnd(1,1,N);x2=exprnd(1,1,N);

x3=exprnd(1,1,N);x4=exprnd(1,1,N);

x5=exprnd(1,1,N);

x6=exprnd(1,1,N);x7=exprnd(1,1,N);

x8=exprnd(1,1,N);x9=exprnd(1,1,N);

x10=exprnd(1,1,N);xsel=max(max(max(max(max(max(max(max(max(x1,x2),x3),x4),x5),x6),x7),x8),x9),x10);n=1:N;

plot(n(1:10),x1(1:10),'g*',n(1:10),x2(1:10),'k+',n(1:10),xsel(1:10),'rd')ratio1=mean(x1)/std(x1)

ratiosel=mean(xsel)/std(xsel)xlabel('sample number')

ylabel('sample values')legend('any one set','another set','largest of the ten sets')

Page 205: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 205/246

Page 205 of 246

ratio = 0.96ratio = 2.27 (after compounding)

Problem 21. The density function of the SNR (MRC) γ is

( )0

1

0

1

1 !

M

M e

M

γ

γ γ

γ

− −

where0

γ is the average SNR. The probability that the SNR is less than a threshold thγ is given

by( )

[ ]0

1

0

00

1, ,

1 !

th M

th M e d gamcdf M

M

γ γ

γ γ γ γ γ

γ

− −

=−∫

where gamcdf is the cumulative distribution function of the gamma distributed random variable.

We are given that0

γ is 5 dB or 10 and thγ is 0 dB or 1.

The outage probability is 1, , 10 .gamcdf M This function is available in the Statistics

Toolbox.

Page 206: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 206/246

Page 206 of 246

For M=3, the outage is 0.0042.

For M = 4, the outage is 3.2397e-004.

Problem 22. Eqn. (5-18) from the text gives the outage probability for the case of a selection

combiner as

( )0

1 exp th

M γ

γ − − .

For M=3, the outage is 0.0199.For M=4, the outage is 0.0054.

Problem 23. MRCSELcomp

clear%MRCSELcomp.m

%compares the outage due to MRC and selection diversityclose allSNRa=sqrt(3);%average SNR

SNRt=1;%thresholdM=1:8;%diversity order

MRCoutage=gamcdf(SNRt,M,SNRa);SELoutage=(1-exp(-SNRt/SNRa)).^M;semilogy(M,SELoutage,'r',M,MRCoutage,'k'),title('Outage--Diversity')

legend('Selection','MRC')xlabel('M')

ylabel('Outage probability')

Page 207: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 207/246

Page 207 of 246

Problem 24 .pskmargin.m

clearclose all

%pskmargin.m%computes the power margin as a function of the bit error rate for BPSK (Coherent) and DPSK.

%computes the power margin as a function of the bit error rate for BPSK (Coherent) andRayleigh faded CBPSK.for k=1:1001;

ber(k)=1e-6*(k-1)*10;be2=2*ber(k);

ZB=(erfinv(1-be2))^2;%SNR required in BPSK

ZD=-log(be2);%SNR required in DPSKZFD=1/((1/(1-be2))^2-1);%SNR required in fading coherent BPSK

ZDD=1/be2-1;%SNR required in fading DPSKCtoDP(k)=10*log10(ZD)-10*log10(ZB);%excess snr required to have identical error rates

BPSK and DPSKCtoCfad(k)=10*log10(ZFD)-10*log10(ZB);%excess snr required to have identical error rates

BPSK and faded BPSK

Page 208: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 208/246

Page 208 of 246

CDtoCDfad(k)=10*log10(ZDD)-10*log10(ZD);%excess snr between fading and no fading

DPSKend;

figuresemilogx(ber,CtoDP);

xlabel('bit error rate')ylabel('Power Margin dB: DPSK-CBPSK')figure

semilogx(ber,CtoCfad);xlabel('bit error rate')ylabel('Power Margin dB: CBPSK(Rayleigh fading-no fading)')

figuresemilogx(ber,CDtoCDfad);

xlabel('bit error rate')ylabel('Power Margin dB: DPSK-fading DPSK')

Problem 25.See pskmargin.m in solution to exercise # 24.

Page 209: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 209/246

Page 209 of 246

Problem 26. We have seen (see Problem #27 of Chapter 2) that a Rician approaches a

Gaussian when the Rician parameter K (dB) goes up. Thus, because of the existence of the LOSpath, the Rician channel approximates to a Gaussian as K increases. Rayleigh channel, on theother hand, will approach a Gauusian channel only if diversity is used. In other words, the

performance of the communication systems in Rician channels will be better than theperformance in Rayleigh channels.

Problem 27. channelcapray.m , cap.m, and cap2.m

%channelcapray.m

clearclose all%computes the channel capacity in Rayleigh fading and in diversity

%C=log2(1+snr); snr will be exponentially distributed with the parameter average snrglobal snra

global MM=4;for k=1:30;

Page 210: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 210/246

Page 210 of 246

kr=-10+k;

snra=10^(kr/10);sn(k)=kr;%signal-to-noise raio in dB

aa=quadl('cap',0,pi/2);ab=quadl('cap2',0,pi/2);

cr(k)=aa;%Rayleigh faded capacityc(k)=log2(1+snra);%Gaussian channelcab(k)=ab;%MRC diversity M=4

end;plot(sn,c,'k',sn,cr,'r',sn,cab,'g');xlabel('average signal-to-noise ratio dB');

ylabel('average spectral efficiency bits/s/Hz')

function y=cap(x)global snra

xx=tan(x);xy=log2(1+xx);

x1=sec(x);x2=x1.^2;ex=exp(-xx/snra);

y=(1/snra)*ex.*xy.*x2;

function yy=cap2(x)global snra

global Mxx=tan(x);

xy=log2(1+xx);x1=sec(x);x2=x1.^2;

ex=exp(-M*xx/snra);M1=(M^M)/gamma(M);

y1=xx.^(M-1);yy=((1/snra)^M)*M1*ex.*xy.*y1.*x2;

Page 211: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 211/246

Page 211 of 246

Problem 28. See channelcapray.m, cap.m, and cap2.m in the solution to the Problem #

27.

Problem 29. channelcapNaka.m and capnaka.m

%channelcapNaka.mclose all

clear%computes the channel capacity Nakagami fading%C=log2(1+snr); snr will be exponentially distributed with the parameter average snr

m=[1 1.5 2 5];

global snraglobal mmfor k=1:4

mm=m(k);

for k=1:30;kr=-10+k;

snra=10^(kr/10);sn(k)=kr;%signal-to-noise raio in dB

Page 212: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 212/246

Page 212 of 246

abn=quadl('capnaka',0,pi/2);

cn(k)=abn;%Nakagami fadedc(k)=log2(1+snra);%Gaussian channel

end;plot(sn,cn,'r');

xlabel('average signal-to-noise ratio dB');ylabel('average spectral efficiency bits/s/Hz')hold on

end;plot(sn,c,'k')

function yy=capnaka(x)global snra

global mmxx=tan(x);xy=log2(1+xx);

x1=sec(x);x2=x1.^2;

ex=exp(-mm*xx/snra);M1=(mm^mm)/gamma(mm);y1=xx.^(mm-1);

yy=((1/snra)^mm)*M1*ex.*xy.*y1.*x2;

Page 213: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 213/246

Page 213 of 246

Problem 30. Results of Problem #29 show that as the value of m increases, the channel

capacity approaches that of an ideal channel. When m increases beyond 1, the Rician parameter

K also increases (See Problem #27 of Chapter 2) with m. Thus, the performance of Rician

channel will approach that of an ideal channel when K becomes large.

Problem 31. Results of Problems #16 and #17 show that when the Nakagami

parameter goes up from m=1, the error probability (for a given SNR) starts coming down. If we

explore the properties of the Nakagami density functions and the pdf of the sum of twoNakagami distributed random variables, it can be shown that the sum of two Nakagamidistributed random variable is another Nakagami random variable with vale of msum =2m. The

equal gain diversity combination will lead to the sum of two envelopes from the two branches,

each Nakagami distributed. The sum will once again be Nakagami distributed with an m-valueequal to twice the m-value of the individual branch. Based on the results of exercises #16 and 17,it can now be concluded that the increase in m value of the envelope brought on throughdiversity will lead to lower error probabilities.

Problem 32. bpskfaddivM.m

***An important note**** When simulations are undertaken using random numbers, it must beremembered that you may need to do the simulation a few times to verify the conclusions.

Page 214: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 214/246

Page 214 of 246

clear

%bpskfaddivM.m fading%three pulses are added

close all%examines the fading of pulse/shapes

%the program prompts the fractional delays; noise added. demodulation of the faded andunfaded BPSK modulation schemes%equal gain diversity is used

fc=10e3;%carrier frequencyppf=2*pi*fc;fs=12*fc;%sampling rate

ddt=1/fs;nn=1e-3/ddt;%total number of samples in one m sec

M=2^(nextpow2(nn));N=8;%number of bitsa=[1 1 -1 -1 -1 1 -1 1];

kp=floor(nn/8);%creates the width of the pulsedel=0.3;%'enter the fractional (of the duration) delay...between 0.25 and 0.75.>>');

dd1=round(del*kp);del2=0.56;%('enter the fractional (of the duration) second delay...between 0.25 and 0.75.>>');dd2=round(del2*kp);

%sd=input('enter the std dev.of additive white noise (fraction of the signal voltage..0.02-0.7.>>');sd=0.1;%std dev.of additive white noise (fraction of the signal voltage..0.02-0.7.

sdiv=[zeros(1,kp*8)];mdiv=input('enter the order of diversity to be used 1,2,..10 or 15 >>>');

for kdiv=1:mdiv;%diversity of orderfor ku=1:8;

for k=(ku-1)*kp+1:kp*kutt(k)=k*ddt;s(k)=a(ku);%creates the pulse stream

sf(k)=a(ku)*cos(ppf*tt(k));%rf pulsesf1(k)=5*rand(1)*cos(ppf*tt(k)+2*pi*rand(1));%random phase, random amplitude

sf2(k)=10*rand(1)*cos(ppf*tt(k)+2*pi*rand(1));%random phase,random amplitudeend;

end;

for k=1:kp*ku;if k<=dd1

ss1(k)=0;else

ss1(k)=s(k-dd1);%creates a delayed pulse stream

end;end;

for k=1:kp*ku;tt2(k)=k*ddt;

Page 215: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 215/246

Page 215 of 246

if k<=dd2

ss2(k)=0;else

ss2(k)=s(k-dd2);%creates a delayed pulseend;

end;sum=s+ss1+ss2;%added pulse shapessum=sum/max(abs(sum));%normalizes to unity

rfsum=sf+sf1.*ss1+sf2.*ss2;%added RF pulses, delayed, randomly weightedrfsum=rfsum/max(abs(rfsum));%normalizes to unityfor k=1:kp*8;

sfd(k)=(rfsum(k)+normrnd(0,sd))*2*cos(ppf*tt(k));%coherent demodulation fading with noisessfd(k)=(sf(k)+normrnd(0,sd))*2*cos(ppf*tt(k));%coh. demodulation no fading

end;[bb,aa]=butter(10,.2);sfd=filtfilt(bb,aa,sfd);

ssfd=filtfilt(bb,aa,ssfd);sdiv=sdiv+sfd;%add the demodulated signals from diversity

end;sdiv=sdiv/max(abs(sdiv));%normalizesfd=sfd/max(abs(sfd));

ssfd=ssfd/max(abs(ssfd));plot(tt*1e3,s,tt*1e3,sf),title('bit stream [1 1 -1 -1 -1 1 -1 1]')

ylim([-2 2]);xlabel('time ms')ylabel('volts')

legend('input bit stream','input RF bit stream')figure

plot(tt*1e3,sum,tt*1e3,rfsum),title('fading-effects of delay and random phase')ylim([-2 2]);xlabel('time ms')

ylabel('volts')legend('bit stream in fading','RF bit stream in fading')

sfd=sfd/abs(max(sfd));ssfd=ssfd/abs(max(ssfd));mmd=num2str(mdiv);

title2=strcat('effect of diversity',' order= ', mmd)figure

plot(tt*1e3,s,'r',tt*1e3,ssfd,'k',tt*1e3,sfd,'g',tt*1e3,sdiv,'b'),title(title2)legend('Data','demodulated data-no fading','demodulated data-fading','diversity')ylim([-2 2])

xlabel('time ms')ylabel('volts')

for kk=1:Nky=kp/2+(kk-1)*kp;

Page 216: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 216/246

Page 216 of 246

if ssfd(ky)>0 %coh. demodulation noise only

b(kk)=1;else

b(kk)=-1;end;

if sfd(ky)>0;%coh. demodulation fadingc(kk)=1;else

c(kk)=-1;end;if sdiv(ky)>0;%coh. demodulation diversity

d(kk)=1;else

d(kk)=-1;end;

end;

'input bit stream'

a'output bit stream..coherent deomodulation'b

'output bit stream coh. demodulation fading'

c'output bit stream coh. demodulation diversity'd

Page 217: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 217/246

Page 217 of 246

Page 218: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 218/246

Page 218 of 246

Page 219: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 219/246

Page 219 of 246

Problem 33. See the m file and diagrams in Problem # 32.

Diversity of order 100

input data

1 1 -1 -1 -1 1 -1 1

output bit stream..coherent deomodulation

1 1 -1 -1 -1 1 -1 1

output bit stream coh. demodulation fading

-1 -1 1 1 1 -1 -1 -1

output bit stream coh. demodulation diversity

1 1 -1 -1 -1 1 -1 1

Page 220: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 220/246

Page 220 of 246

Leibniz’s Rule is used when we have to differentiate an integral. Let

( ) ( )( )

( )

,

b u

a u

G u H x u dx

= ∫ .

We are now interested in finding out the derivative of G w.r.t u.

( ) ( ) ( ) ( ) ( )( )

( )

( ), , ,

b u

a u

d d d G u H b u u b u H a u u a u H x u dx

du du du u

∂= − + ∂∫ .

Page 221: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 221/246

Page 221 of 246

Chapter 6

Problem 1

Frequency

0 5 KHz

Spectrum (Magnitude)

The bandwidth available = 400 KHz.

Number of channels available =400

805

= .

Problem 2

Page 222: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 222/246

Page 222 of 246

2.

BPF LPF message

BPF LPFmessage

BPF LPFmessage

BPF LPFmessage

BPF LPF message

BPF LPFmessage

cos(2πf ck t)

cos(2πf ck+1t)

cos(2πf ck-1t)

Problem 3. cdmapulse.m

clear%cdmapulse.m

%generates the CDMA pulsesclose allN=8;

T=512;Tc=T/N;

Page 223: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 223/246

Page 223 of 246

for k=1:1024;

x(k)=k;if k<=512

y(k)=1;else

y(k)=-1;end;end;

for jp=1:2*N;%generates +1 and -1 with equal probability;xj=rand(1);

if xj <=0.5a(jp)=-1;

elsea(jp)=1;

end;

end;

for kk=1:1024;xx(kk)=kk;kf=floor((kk-1)/Tc);

jj=1+kf;%creates the chipsyy(kk)= a(jj);

zz1=yy(kk)+y(kk);if zz1==0

z(kk)=1;%modulo 2 addition....-1+1 and 1+-1 ==1, -1+-1 and +1+1==0

elsez(kk)=0;

end;end;

figuresubplot(3,1,1);

plot(x,y,'k'), title('two bits')axis off %ylim([-1.5 1.5]);

subplot(3,1,2);

plot(xx,yy,'k'), title('chip sequence')axis off

%ylim([-1.5 1.5]);

subplot(3,1,3);plot(x,z,'k'),title('modulo 2 addition of chip and data sequences')axis off

Page 224: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 224/246

Page 224 of 246

%ylim([-1.5 1.5]);

figurefor mm=1:1024

if mm<=512yb(mm)=y(mm);

elseyb(mm)=0.0;end;

if mm<=64yyb(mm)=yy(mm);

else

yyb(mm)=0.0;end;

end

plot(x,abs(fft(yb,1024))/max(abs(fft(yb,1024))),'r',x,abs(fft(yyb,1024))/max(abs(fft(yyb,1024))),'

k');xlim([0 64])xlabel('sample number')

ylabel('Normalized spectrum')legend('data','chip')

figurebpy=yy.*cos(2*pi*(1/Tc)*x);

figure

plot(x,bpy,'.')

ylim([-2 2])

ylabel('BPSK-DSSS signal')xlabel('sample number')

xlim([1 1024])

Page 225: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 225/246

Page 225 of 246

Problem 4. cdmapulse.m (See the m file in Problem #3)

Note that the 8th zero crossing of the bit spectrum falls on the first zero crossing of the chipspectrum. In other words, there is 1:8 bandwidth expansion factor

Page 226: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 226/246

Page 226 of 246

Problem 5. cdmapluse (see the m file in Problem # 3)

Page 227: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 227/246

Page 227 of 246

Problem 6. Number of users or channels =64

Data rate= 4800 bps

BER in the absence of any thermal noise =1

2 1

K erfc

k

− where K is the processing

gain.

Thus, 3 1 110 1

2 63 2 63

K K erfc erf −

= = −

. Using erfinv command from MATLAB,

we can write ( )2363 1 2 10K erfinv − = × − × =301.

Chip rate = 4800 301× =1.448 megachips/s.

Problem 7. The BER is given by1

2 1

K erfc

k

− with K=1000 and BER =10-6.

Page 228: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 228/246

Page 228 of 246

The number of users is given by

( )2

6

10001 90

1 2 10erfinv−

+ = − ×

.

Problem 8. Processing gain = 20 dB 100→ =chiprate

datarate.

Therefore, the chip rate must be 9600 100 96kbps× = .

Problem 9. Length of the PN sequence 102 1 2 1 1023m N = − = − = .

Bit duration = 1023 .1 102.3s sµ µ× = .

Processing Gain = ( )1010log 1023 30dB= .

Problem 10. The difference in propagation delay corresponding to a distance of 200 meters

=8

2000.666

3 10

sµ=

×

where we have used the speed of the e.m wave to be 83 10 / m s× . The

minimum chip rate is6

1 10 /

.666 10 6megachips s− =

×.

Problem 11. Consider a chip sequence of length K. A single chip is shown in Figure Ex. 6-9.

Its autocorrelation will be of triangular shape as shown.

Let p(t) be the chip shape as shown. The PN stream b(t) can be written as

( ) ( )n c

n

b t a t nT ∞

=−∞

= −∑ .

The chip sequence an is periodic, i.e., n n K a a += . Thus, the period of the PN stream is will be the

time occupied by the sequence, i. e., KTc.

timeTc

1

Tc-Tc

Page 229: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 229/246

Page 229 of 246

The autocorrelation is now carried out over the whole period of the sequence, i.e., KTc. The

autocorrelation Rb(τ) is given by

( ) ( ) ( )0

1 cKT

b

c

R b t b t dt KT

τ τ= +∫ .

The autocorrelation Rb(τ) can be rewritten as

( ) ( ) ( )1

0 0

1.

cKT K

b n m c c

n mc

R a a p t KT p t KT dt KT

τ τ−

=

= − + −∑∑ ∫

The inner summation over m depends on the value of t since the summation can start somewherein the middle of the period and continue to the middle of the next period. The summation overthe chip values (property of the PN sequence) can be obtained easily by noting that

( )1

0, ,2 ,...

1

K

k k m

k

K fo rm K K C m a a

elsewhere+

=

== = −

∑ .

The autocorrelation function now becomes

Page 230: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 230/246

Page 230 of 246

( )( ) ( )

( )

1, 0

1, 1

p p c c

b

c c

R R T T K

R

T K T K

τ τ τ

τ

τ

− − ≤ ≤= − ≤ ≤ −

where

( ) ( ) ( )1

p

c

R x p t p t x dxT

−∞

= +∫ .

Noting that the autocorrelation of the chip shape is triangular, the autocorrelation functionbecomes

( )1 1

1 cb

n c

nKT R

K T K

ττ

=−∞

− = + Λ −

∑ .

Page 231: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 231/246

Page 231 of 246

Problem 12. The power spectral density can be easily obtained by observing that the

autocorrelation function is periodic, with a period of KTc. The basic shape is triangular with awidth of 2Tc. Since the autocorrelation function is periodic, we may write it as

( )02

e

j nf

b nn R r

π τ

τ

=−∞= ∑with f 0=

1

cKT and rn are the Fourier series coefficients. Since the Fourier transform of a triangular

pulse shape is a 2sin c function, we may write the power spectral density of the PN stream Ps(f)as

( ) ( ) ( )0s b n

n

P f R r f nf τ δ∞

=−∞

= ℑ = − ∑where

2

2

2

1 , 0

sin1

, 0

n

nK

nr

K K n

nK

K

π

π

= = + ≠

Thus, the PSD contains a series of delta functions.

Page 232: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 232/246

Page 232 of 246

Problem 13.CDMAcor3.m

%CDMAcor3.m correlation of PN sequences of length 7%alows two sets of inputsclear

N=7;a=[1 -1 -1 1 -1 +1 1]; %first set

loopagn = ['y'];while(loopagn == 'y')

close allT=5;%Chip duration time units

MM=64;%number of sequencesNT=N*T;

Page 233: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 233/246

Page 233 of 246

for kn=1:MM;

kb1=(kn-1)*NT;for kb=1:NT;

zz=1+floor((kb-1)/T);%this gives the chips of duration T and will repeat after 7 bitsy(kb1+kb)=a(zz);

x(kb1+kb)=kb1+kb;end;end;

plot(x,y),title('64 chip sequences, each sequence of length 7');ylim([-2 2])xlim([0 140])

figurez=xcorr(y,'biased');%this is the correlation with MM sequences with itself; biased

normalizesx1=[1:2*NT*MM-1];%creates the X-coordinatesx2=x1-NT*MM;%shifts the center to the origin

plot(x2,z),title('A single period of the correlation function')xlim([-20 20])

grid onfigureplot(x2,z),title('Multiple periods of the correlation function')

xlim([-40 40])grid on

min(z)% this gives the min of the autocorrelation =-1/N%check is this value equal to 1/N[px f]=psd(y,length(y),1);%power spectral density

figureplot(f,px/length(px)),title('Power Spectral Density of the PN sequence')

xlabel('Frequency')ylabel('PSD')loopagn = input('\n Do you want to look a second set (type y for yes): ', 's');

a=[-1 +1 +1 -1 +1 -1 -1];%second setend

Page 234: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 234/246

Page 234 of 246

Page 235: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 235/246

Page 235 of 246

Problem 14. See the m file in Problem #13 .

Answer -0.1473

Problem 15.

Page 236: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 236/246

Page 236 of 246

Problem 16.CDMAspec.m

%CDMAspec.m calculates the PSD of a CDMA sequenceclearN=7;

a=[1 -1 -1 1 -1 +1 1];%calculates the correlation function of the PN sequence

close allfc=20e3;%carrier frequencyppf=2*pi*fc;

fs=10*fc;%sampling rateddt=1/fs;

nn=1e-3/ddt;%total number of samples in one m sec

kp=floor(nn/8);%creates the width of the pulsekw=0;

for MM=1:16for ku=1:N;

for k=(ku-1)*kp+1:kp*kukw=kw+1;

tt(kw)=kw*ddt;

s(kw)=a(ku);%creates the pulse stream

Page 237: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 237/246

Page 237 of 246

sf(kw)=a(ku)*cos(ppf*tt(kw));

end;end;

end;figure

plot(tt*1e3,s), title(' two sequences, each of length 7 b(t)');xlim([0 14*kp*ddt*1e3])xlabel('time ms')

ylim([-2 2])

y=fft(s,2048);%FT of the sequence giving the PSD

f=fs*(0:length(y)/2)/length(y);px=y.*conj(y)/length(y);%PSD

figureplot(f*1e-3,px(1:length(f))),title('PSD of the PN sequence')xlabel('Frequency KHz')

px(1)

figureplot(tt*1e3,sf),title('b(t)cos(2\pif_ct)')

xlim([0 14*kp*ddt*1e3])ylim([-2 2])

xlabel('time ms')

yy=fft(sf,2048);%FT of the correlation giving the PSD

f=fs*(0:length(yy)/2)/length(yy);pxy=abs(yy)/length(yy);%PSD

figureplot(f*1e-3,pxy(1:length(f))), title('PSD of b(t)cos(2\pif_ct)') ;xlabel('Frequency KHz')

b(t) is the chip sequence.

Page 238: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 238/246

Page 238 of 246

Page 239: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 239/246

Page 239 of 246

Problem 17 .use CDMAcor3.m of Problem # 13.

Page 240: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 240/246

Page 240 of 246

Page 241: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 241/246

Page 241 of 246

The results are similar to those of exercise #13.

Problem 18. CDMAcor30.m

%CDMAcor30.m correlation of CDMA sequences with 0 in place of -1

clearclose allN=7;

a=[[1 0 0 1 0 +1 1]];%calculates the correlation function of the PN sequence

close allT=5;%Chip duration time units

MM=64;%number of sequencesNT=N*T;for kn=1:MM;

kb1=(kn-1)*NT;for kb=1:NT;zz=1+floor((kb-1)/T);%this gives the chips of duration T and will repeat after 7 bits

y(kb1+kb)=a(zz);x(kb1+kb)=kb1+kb;

Page 242: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 242/246

Page 242 of 246

end;

end;plot(x,y),title('64 chip sequences, each sequence of length 7');

ylim([-2 2])xlim([0 140])

figurez=xcorr(y,'biased');%this is the correlation with MM sequences with itself; biasednormalizes

x1=[1:2*NT*MM-1];%creates the X-coordinatesx2=x1-NT*MM;%shifts the center to the origin

plot(x2,z/max(z)),title('A single period of the correlation function')

xlim([-20 20])grid on

figureplot(x2,z/max(z)),title('Multiple periods of the correlation function')xlim([-40 40])

grid on

Page 243: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 243/246

Page 243 of 246

Note that the correlation is always positive.

Problem 19. Slow hopping. Processing gain= 5x3= 15 or 10xlog10(15) =11.8 dB

Problem 20.

%problem6_20.m%calculates the loading factor as a function of the signal-to-noise ratio

%voice activity reduction, intercell interference etc.clear allclose all

snreq=10; %snr required in dBsn=10^(0.1*snreq);%snr in absolute units

alpha=1;aff(1)=1.2;aff(2)=2.0

for kp=1:2af=aff(kp);

for kk=1:20;xxn=snreq+2*kk;

Page 244: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 244/246

Page 244 of 246

x(kk)=xxn;%thermal noise SNR in dB

xx=10^(.2*xxn);yr(kk)=(1/xx)*(xx-sn)*(1/alpha)*(1/(1+af));

xs(kk)=xxn-sn;%the difference in SNR;end;

subplot(2,1,kp)fval=num2str(af);title1=strcat('f=',fval)

plot(x,yr),title(title1)xlabel('(E/N_0)_s')ylabel('cell utilization N_u')

end;

10 15 20 25 30 35 40 45 500.43

0.44

0.45

0.46

f=1.2

(E/N0)s

c e l l u t i l i z a t i o n

N u

10 15 20 25 30 35 40 45 500.32

0.33

0.34

f=2

(E/N0)s

c e l l u t i l i z a t i o

n

N u

Problem 21.

Page 245: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 245/246

Page 245 of 246

%problem6_21.m

%calculates the reduction in signal-to-noise ratio as the number of users%increase

clearsnr=10%minimum acceptable snr in dB

sn=10^(snr/10);%snr in absolute unitsK=64;%512/8

Nmax=floor(1+K/sn)%maximum number of ideal users..integer valuestn=18;%signal-to-thermal noisestnu=10^(stn/10);%snr in absolute units

for kk=1:60;N1=Nmax+(kk-1);

N(kk)=N1-Nmax;%additional usersy1=N1-1+K*(1/stnu);snn=K/y1;

y(kk)=10*log10(snn);%effective snr in dBend;

plot(N,y)xlabel('Number of additional users')ylabel('Effective signal-to-noise ratio')

ylim([0 10])

Page 246: Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

7/23/2019 Introduction To Wireless Systems - P M Shankar - Solutions Manual.pdf

http://slidepdf.com/reader/full/introduction-to-wireless-systems-p-m-shankar-solutions-manualpdf 246/246

7

8

9

10

e

r a t i o