Scenario 2 code

= Scenario 2 code =

Main
function [r1,r2] = LossPlot model = 1; dist = 1; freq = 2400; PT1 = 20; GR1 = 3; GT1 = 5; [x1,y1] = wlan(freq); x2 = 0:1:dist*1000; y1 = y1+(PT1+GR1+GT1); y2 = zeros(1,dist*1000+1); RS1 = Srdb(20000, 4, 293.15, 3, 11264); fade1 = fading_margin(0.95, freq); noise1 = RS1 + fade1; noise1Plot(1:(dist*1000+1)) = noise1; RS1Plot(1:(dist*1000+1)) = RS1; plot(x1, y1, 'g-'); hold on; plot(x2, y2, 'k-'); plot(0:dist*1000, noise1Plot, 'r-'); plot(0:dist*1000, RS1Plot, 'b-'); [i1,i2] = intersections(x1,y1,0:dist*1000,noise1Plot,1); plot(i1,i2, 'r-*'); hold off; axis([0 1000 -100 5]) set(gca,'XTick',0:50:dist*1000)

r1 = i1; r2 = i2; % r3 = dist-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 UMTS','Fading margin WLAN 802.11b', 'Receiver sensitivity WLAN 802.11b'); end

Freespace
function [ Dist, PathLoss ] = wlan(freq) Dist=0:0.1:10;                  % Distance Dist_m = Dist*100;

Freq=freq;             % Frequence c=3*1e8;               % Speed of light lamda=c/(Freq*1e6);    % Lamda, Wavelength

% Free Space Model (Urban) FreeSpace=10*log10((Dist_m*pi*4).^2/lamda^2); PathLoss = -FreeSpace; Dist = Dist_m;

end