% plot_two_ray_loss - plot path loss for two ray model

fc = 900e6;
ht = 30;
hb = 2;

n_points = 500;

d = logspace(0, 4, n_points);
pl_db = zeros(size(d));

for nn = 1:n_points
   pl_db(nn)  = two_ray_loss(d(nn), fc, ht, hb);
end

lambda = 3e8/fc;

approx_pg_db = 10*log10(4* (lambda./(4*pi*d)).^2 .* sin(2*pi*ht*hb./(lambda*d)).^2);

%% plot the negative of path loss - this looks more natural
% semilogx(d, -pl_db, d, approx_pg_db);
semilogx(d, -pl_db)
grid on
xlabel('Distance (m)')
ylabel('Path Gain (dB)')
% axis([10^0, 10^4, -150, -30])

%% Store name of script for automated figure generation
ScriptName = mfilename;