Scenario 3 code

= Code for Scenario 3 =

Main
function [r1,r2,r3,r4,r5] = Scenario3(dist) model = 4; dist_m = dist*1000; freq = 2400; freq2 = 5200; tx_ht = 4; rx_ht = 1.8; PT = 20; GR = 3; GT = 9; PT2 = PT; GR2 = GR; GT2 = GT; % [x1,y1] = pathloss(dist, freq, tx_ht, rx_ht, model); % [x2,y2] = pathloss(dist, freq2, tx_ht, rx_ht, model); [x1,y1] = wlan3(dist, freq, tx_ht, rx_ht); [x2,y2] = wlan3(dist, freq2, tx_ht, rx_ht); y1 = y1+(PT+GR+GT); y2 = y2+(PT2+GR2+GT2); RS1 = Srdb(20000, 4, 293.15, 3, 10240); RS2 = Srdb(20000, 4, 293.15, 3, 10240); fade1 = fading_margin(0.95, freq); fade2 = fading_margin(0.95, freq2); noise1 = RS1 + fade1; noise2 = RS2 + fade2; 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, 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--'); [i1,i2] = intersections(x1,y1,0:dist_m,noise1Plot,1); plot(i1,i2, 'r-*'); [i3,i4] = intersections(x2,fliplr(y2),0:dist_m,noise2Plot,1); plot(i3,i4, 'r-*'); hold off; % set(gca,'XTick',0:0.01:dist*1000)

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('Signal strength 802.11b 2400 MHz', 'Signal strength 802.11a 5200 MHz', 'Fading margin 802.11b', 'Fading Margin 802.11a', 'Receiver sensitivity 802.11b', 'Receiver Sensitivty 802.11a'); end

Modified Hata
function [ Dist, PathLoss ] = wlan3(distance, freq, txh, rxh) Dist = 0:0.01: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

end