Scenario 4 code

From its-wiki.no
Jump to: navigation, search

Scenario 4 code

Main

function [r1,r2,r3,r4,r5] = Scenario4(dist)
model = 4;
dist_m = dist*1000;
freq = 2100;
tx_ht = 150;
rx_ht = 1.5;
PT = 25;
GR = 2;
GT = 14;
[x1,y1] = pathloss_orig(dist, freq, tx_ht, rx_ht, model);
x1=x1*1000;
y1 = y1+(PT+GR+GT);
RS1 = Srdb(200, 4, 293.15, 3, 12.2);
fade1 = fading_margin(0.95, freq);
noise1 = RS1 + fade1;
noise1Plot(1:(dist_m+1)) = noise1;
RS1Plot(1:(dist_m+1)) = RS1;
plot(x1, y1, 'g-');
hold on;
plot(x1-1000, fliplr(y1), 'k-');
plot(0:dist_m, noise1Plot, 'r-');
plot(0:dist_m, RS1Plot, 'b-');
[i1,i2] = intersections(x1,y1,0:dist_m,noise1Plot,1);
plot(i1,i2, 'r-*');
[i3,i4] = intersections(x1-1000,fliplr(y1),0:dist_m,noise1Plot,1);
plot(i3,i4, 'r-*');
hold off;
set(gca,'XTick',0:1000:dist_m)

r1 = i1;
r2 = i2;
r3 = dist_m-i3;
r4 = i4;
r5 = i1-i3;

if(model==1)
    title('Propagation prediction - Freespace');        % 1: FreeSpace
elseif(model==2)
    title('Propagation prediction - Okumura');          % 2: Okumura
elseif(model==3)
    title('Propagation prediction - Hata Urban');       % 3: Hata Urban
elseif(model==4)
    title('Propagation prediction - Hata Suburban');    % 4: Hata Suburban
elseif(model==5)
    title('Propagation prediction - Hata Open');        % 5: Hata Open
elseif(model==6)
    title('Propagation prediction - Lee Philadelphia'); % 6: Hata Urban
elseif(model==7)
    title('Propagation prediction - Lee Newark');       % 7: Hata Urban
elseif(model==8)
    title('Propagation prediction - Lee Tokyo');        % 8: Hata Urban
elseif(model==9)
    title('Propagation prediction - ETSI');             % 9: Hata Urban
end

xlabel('Distance (m)');
ylabel('Signal strength (dB)');
legend('UMTS2100','UMTS2100','Fading Margin UMTS','Receiver Sensitivty UMTS');
end

Modified pathloss

function [ Dist, PathLoss ] = pathloss_orig(distance, freq, txh, rxh, model)
Dist=1:0.01:distance;                    % Distance
Dist_Km=Dist;                       % Distance in km
Dist_m=Dist*1000;                   % Distance in meters
Dist_Log_Km=log10(Dist_Km);            % Distance in Log Scale (for km)
Dist_Log_Meter=log10(Dist_m);       % Distance in Log Scale (for meters)

Freq=freq;              % Frequence
c=3*1e8;                % Speed of light 
lamda=c/(Freq*1e6);     % Lamda, Wavelength
TX_Ht=txh;              % Height of transmit antenna
RX_Ht=rxh;              % Height of receive antenna

% Free Space Model (Urban)
FreeSpace=10*log10((Dist_m*pi*4).^2/lamda^2);
    
% Okumura Model (Urban)
Lf = FreeSpace;             % Free Space Propagation Loss
Amu = 35;                   % Median Attenuation Relative to Free Space (900 MHz and 30 Km)
Garea = 9;                  % Gain due to the Type of Environment (Suburban Area)
Ghte = 20*log(TX_Ht/200);   % Base Station Antenna Height Gain Factor
if(RX_Ht>3)
Ghre = 20*log(RX_Ht/3);
else
Ghre = 10*log(RX_Ht/3);
end
Okumura=Lf+Amu-Ghte-Ghre-Garea;

% Hata Model
PAR_H=3.2*((log10(11.75*RX_Ht))^2)-4.97;
Hata_Urban=69.55+26.16*log10(Freq)-13.82*log10(TX_Ht)-PAR_H+((44.9-6.55*log10(TX_Ht)))*(Dist_Log_Km);

Hata_Suburban=Hata_Urban-((2*(log10(Freq/28))^2)-5.4);

Hata_Open=Hata_Urban-((4.78*(log10(Freq))^2)+(18.33*log10(Freq))-40.94);

% Lee's Urban Model for Philadenphia, Newark and Tokyo
ALPH1=(TX_Ht/30.48)^2;  % F1
ALPH2=10^(6/40);        % F2: Base Station antenna gain is 6/4 dB corresponding to 10^(6/40) actual value
if(RX_Ht>3)
	ALPH3=(RX_Ht/3)^2;  % F3
else
    ALPH3=(RX_Ht/3);    % F3
end
ALPH4=1;                % F4: (freq/900)^-n      # Assuming 900MHz
ALPH5=0.25;             % F5: alpha5=-6dB corresponding to 0.25 actual value

ALPH0=ALPH1*ALPH2*ALPH3*ALPH4*ALPH5;

Lee_Philadenphia=108.49+36.8*(log10(Dist_Km))-10*log10(ALPH0);
Lee_Newark=101.20+43.1*(log10(Dist_Km))-10*log10(ALPH0);
Lee_Tokyo=123.77+30.5*(log10(Dist_Km))-10*log10(ALPH0);


% ETSI vehicular
% Lvehicular = 40 ( 1-4*10^-3 TXH ) log r - 18 log TXH + 21 log f + 80
ETSI=40*(1-4*(10^-3)*TX_Ht)*(Dist_Log_Km)-(18*Dist_Log_Km)+(21*log10(Freq)+80);


PathLoss=0;

if(model==1)
    PathLoss=-FreeSpace;        % 1: FreeSpace
elseif(model==2)
    PathLoss=-Okumura;          % 2: Okumura
elseif(model==3)
    PathLoss=-Hata_Urban;       % 3: Hata Urban
elseif(model==4)
    PathLoss=-Hata_Suburban;    % 4: Hata Suburban
elseif(model==5)
    PathLoss=-Hata_Open;        % 5: Hata Open
elseif(model==6)
    PathLoss=-Lee_Philadenphia; % 6: Hata Urban
elseif(model==7)
    PathLoss=-Lee_Newark;       % 7: Hata Urban
elseif(model==8)
    PathLoss=-Lee_Tokyo;        % 8: Hata Urban
elseif(model==9)
    PathLoss=-ETSI;             % 9: Hata Urban
else
    PathLoss=PathLoss;          % BLABLA
end


end