function [ Dist, PathLoss ] = pathloss(distance, freq, txh, rxh, model)
Dist=1: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