% plot_TwoRay3D - plot path Loss for 2-ray model over d and f

%% Parameters
hb = 7.5;    % base station antenna height
hm = 1.5;    % mobile antenna height
fc = 1e9 + (-50:50)*1e6;   % frequency range
d = logspace(1,3,100);     % range of distances

c = 299792458;    % speed of light
lambda = c./fc;    % wavelength

%% PathLoss
PL = zeros( length(d), length(lambda) );

for kk = 1:length(d)
    PL(kk, : ) = 10*log10( ( 2*lambda ./ (4*pi*d(kk)) ).^2 .* ...
        ( sin( 2*pi*hb*hm ./ (lambda*d(kk)) ) ).^2 );
end

%% 3D plot
surfc( d, fc/1e9, PL' )
set(gcf, 'Position', [4 34 1273 910]);   % full screen
set(gca, 'XScale','log');                % make x-axis logarithmic
axis( 'tight' );
xlabel( 'Distance (m)' );
ylabel( 'Frequency (GHz)' );
zlabel( 'Path Loss (dB)' );

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