Scenario 1 code

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

Code for Scenario 1

function [r1,r2,r3,r4] = LossPlot(mod)
model = mod;
dist = 15;
freq = 1800;
freq2 = 2100;
tx_ht = 150;
rx_ht = 1.5;
PT = 25;
GR = 2;
GT = 14;
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);
y1 = y1+(PT+GR+GT);
y2 = y2+(PT2+GR2+GT2);
RS1 = Srdb(200, 4, 293.15, 3, 12.2);
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;
noise1Plot(1:(dist+1)) = noise1;
noise2Plot(1:(dist+1)) = noise2;
RS1Plot(1:(dist+1)) = RS1;
RS2Plot(1:(dist+1)) = RS2;
plot(x1, y1, 'g-');
hold on;
plot(x2(10:1:(dist+9))-1, fliplr(y2(10:1:(dist+9))), 'k-');
plot(x2, y2, 'k--');
plot(0:dist, noise1Plot, 'r-');
plot(0:dist, noise2Plot, 'r--');
plot(0:dist, RS1Plot, 'b-');
plot(0:dist, RS2Plot, 'b--');
[i1,i2] = intersections(x1,y1,0:dist,noise1Plot,1);
plot(i1,i2, 'r-*');
[i3,i4] = intersections(x2(10:1:(dist+9))-1,fliplr(y2(10:1:(dist+9))),0:dist,noise2Plot,1);
plot(i3,i4, 'r-*');
[i5,i6] = intersections(x2,y2,0:dist,noise2Plot,1);
plot(i5,i6, 'r-*');
plot(((dist-1):0.1:(dist-0.1)),fliplr(y2(1:1:10)),'k-');
hold off;
set(gca,'XTick',1:dist)

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 (km)');
ylabel('Signal strength (dB)');
legend('GSM1800','UMTS2100','UMTS2100','Fading margin GSM', 'Fading Margin UMTS', 'Receiver sensitivity GSM', 'Receiver Sensitivty UMTS');
end