Scenario 2 alternate code

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

Scenario 2 alternate code

Main

function [r1,r2,r3,r4] = Scenario2(dist)
model = 4;
dist_m = dist*1000;
freq = 2400;
freq2 = 2100;
tx_ht1 = 0.1;
tx_ht2 = 90;
rx_ht = 1.5;
PT1 = 20;
GR1 = 3;
GT1 = 9;
PT2 = 25;
GR2 = 2;
GT2 = 14;
[x1,y1] = wlan3(dist, freq, tx_ht1, rx_ht);
% [x1,y1] = pathloss(dist, freq, tx_ht1, rx_ht, model);
[x2,y2] = pathloss_orig(dist, freq2, tx_ht2, rx_ht, model);
x2 = x2*1000;
% x2 = 0:1:dist*1000;
y1 = y1+(PT1+GR1+GT1);
% y2 = zeros(1,dist*1000+1);
y2 = y2+(PT2+GR2+GT2);
RS1 = Srdb(20000, 4, 293.15, 3, 11264);
RS2 = Srdb(3840, 4, 293.15, 3, 12.2);
fade1 = fading_margin(0.95, freq);
fade2 = fading_margin(0.95, freq2);
noise1 = RS1 + fade1;
noise2 = RS2 + fade2;
handover = -66;
handoverPlot(1:(dist_m+1)) = handover;
noise1Plot(1:(dist_m+1)) = noise1;
noise2Plot(1:(dist_m+1)) = noise2;
RS1Plot(1:(dist_m+1)) = RS1;
RS2Plot(1:(dist_m+1)) = RS2;
plot(x1, y1, 'g-');
hold on;
plot(x2-1000, fliplr(y2), 'k-');
plot(0:dist_m, noise1Plot, 'r-');
plot(0:dist_m, noise2Plot, 'r--');
plot(0:dist_m, RS1Plot, 'b-');
plot(0:dist_m, RS2Plot, 'b--');
plot(0:dist_m, handoverPlot, 'm--');
[i1,i2] = intersections(x1,y1,0:dist_m,noise1Plot,1);
plot(i1,i2, 'r-*');
[i3,i4] = intersections(x1,y1,0:dist_m,handoverPlot,1);
plot(i3,i4, 'r-*');
hold off;
% set(gca,'XTick',0:0.01:dist*1000)

r1 = i1;
r2 = i2;
r3 = i3;
r4 = i4;

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('Signal strength WLAN 802.11b','Signal strength UMTS2100','Fading margin WLAN ','Fading margin UMTS', 'Receiver sensitivity WLAN', 'Receiver sensitivity UMTS', '-66 dB');
end

Hata suburban modified to work below 1 km

function [ Dist, PathLoss ] = wlan3(distance, freq, txh, rxh)
Dist = 0:0.001:distance;                  % Distance
Dist_Km=Dist;                       % Distance in km
Dist_Log_Km=log10(Dist_Km);            % Distance in Log Scale (for km)

Freq=freq;              % Frequence
TX_Ht=txh;              % Height of transmit antenna
RX_Ht=rxh;              % Height of receive antenna


% 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);


    PathLoss=-Hata_Suburban;    % 4: Hata Suburban


Dist = Dist*1000;
end