MATLAB CODE FOR FREE SPACE MODEL:
distance=5000;
distance2=10000;
freq=1800;
freq2=10000;
txh=2.5;
rxh=1.5;
txh2=25;
rxh2=15;
model=1;
Dist=1:0.01:distance;
Dist_Km=Dist;
Dist_m=Dist*1000;
Dist2=1:0.01:distance2;
Dist2_Km=Dist2;
Dist2_m=Dist2*1000;
Freq=freq;
c=3*1e8;
lamda=c/(Freq*1e6);
lamda2=c/(freq2*1e6);
TX_Ht=txh;
RX_Ht=rxh;
TX_Ht2=txh2;
RX_Ht2=rxh2;
% Free Space Model (Urban)
FreeSpace=10*log10((Dist_m*pi*4).^2/lamda^2);
FreeSpace2=10*log10((Dist2_m*pi*4).^2/lamda2^2);
% Okumura Model (Urban)
Lf = FreeSpace;
Amu = 35;
Amu2 = 35;
Garea = 9;
Garea2 = 9;
Ghte = 20*log(TX_Ht/200); Ghte2 = 20*log(TX_Ht2/200);
if(RX_Ht>3)
Ghre = 20*log(RX_Ht/3);
Ghre2 = 20*log(RX_Ht2/3);
else
Ghre = 10*log(RX_Ht/3);
Ghre2 = 10*log(RX_Ht2/3);
end
Okumura=Lf+Amu-Ghte-Ghre-Garea;
Okumura2=Lf+Amu2-Ghte2-Ghre2-Garea2;
PathLoss=0;
if(model==1)
PathLoss=-FreeSpace;
PathLoss2=-FreeSpace2;
elseif(model==2)
PathLoss=-Okumura;
PathLoss2=-Okumura2;
end
plot(PathLoss);
PT = 25;
GR = 2;
GT = 14;
PT2 = 30;
GR2 = 2;
GT2 = 14;
y1 = PathLoss+(PT+GR+GT);
figure(1);
plot(y1);
title('BASE STATION 1 SIGNAL');
y2 = PathLoss2+(PT2+GR2+GT2);
figure (2);
plot(y2);
title('BASE STATION 2 SIGNAL');
RS1 = Srdb(20, 1, 10, 0, 12.2);
RS2 = Srdb(3840, 4, 293.15, 5, 12.2);
% chan=ricianchan;
% y=filter(chan,y1);
% y=y+y1;
% figure;
% plot(y);
x1=Dist;
x2=Dist2;
RS1Plot(1:(Dist+1)) = RS1;
RS2Plot(1:(Dist+1)) = RS2;
figure (3);
x=zeros(1,length(y2));
for i=1:length(x)
x(i)=-150;
end
x(250000:249999+length(x1))=y1;
plot((1:length(x)),x,'g-');
title('COMPARISON OF TWO SIGNALS');
% figure(4);
% plot(x1, y1, 'g-');
hold on;
plot((1:length(y2)), y2, 'b--');
figure(5);
plot(0:Dist, RS1Plot, 'b-');
title('RECEIVER SENSITIVITY');
hold on;
plot(0:Dist, RS2Plot, 'r--');
for i=[Link]length(y2)
if ((x(i)>RS1)||(y2(i)>RS1))
if(x(i)>y2(i))
stt(i)=x(i);
pp(i)=x(i);
else
stt(i)=y2(i);
pqr(i)=y2(i);
end
end
end
pr(1:250000+length(x1))=-130.5;
for i=250001+length(x1):length(y2)
% if(x(i)>y2(i))
% stt(i)=x(i);
pr(i)=y2(i);
% else
stt(i)=y2(i);
% end
end
figure (6);
plot(stt);
hold on;
plot(pp,'g');
title('SIGNAL DURING HANDOFF');