% author: Michal Bok, PWr 2008
clear all;
% hBSef - effective base station antenna height [m]
% 30 <= hBS,ef <= 200 m
ht = 50; %[m]
% hMS - mobile station antenna height [m]
% 1 <= hMS <= 10 m
hr = 2; %[m]
% f - frequency [MHz]
% 150 <= f <= 1500 MHz
f = 1500; %[MHz]
% d - distance between antennas [km]
% 1 <= d <= 20 km
from = 1; %[km]
to = 20; %[km]
precision = 0.001; %[km]
d = from:precision:to; %[km]
% area - area type: {1, 2, 3, 4}
% 1 - small medium-sized city 2 - large city 400 <= f <= 200 MHz
% 3 - suburban area 4 - open area
area = [1,2,3,4]; %{1, 2, 3, 4}
% hL50dB = hata(hBSef, hMS, f, d, area)
L = hata(ht, hr, f, d, area);
clf reset;
plot(d, L,'-');
desc = ['ht = ',num2str(ht),' [m] hr = ',num2str(hr),' [m] f = ',...
num2str(f),' [MHz] d = ',num2str(from),' - ',num2str(to),' [km] every ',...
num2str(precision*1000),' [m]'];
annotation('textbox',[0.15 0.7 0.2 0.2],'String',{desc},'FitBoxToText','on');
grid on;
axis auto;
title({'d - distance between antennas [km] / L - radio signal attenuation [dB]';...
'attenuation value based on Hata Model'});
xlabel('d [km]');
ylabel('L [dB]');
legend('small medium-sized city','large city','suburban area','open area','location','Best');
s_21 = mean((L(2,:) - L(1,:)));
s_31 = mean((L(1,:) - L(3,:)));
s_41 = mean((L(1,:) - L(4,:)));
disp('MEAN(large_city(d) - medium-sized_city(d)) [dB] = ');
disp(s_21);
disp('MEAN(medium-sized_city(d) - suburban area(d)) [dB] = ');
disp(s_31);
disp('MEAN(medium-sized_city(d) - open aread)) [dB] = ');
disp(s_41);
%fid = fopen('results.txt','wt');
%fprintf(fid,'%6.4f %8.4f %8.4f %8.4f %8.4f\n',[d;L]);
%xlswrite('results.xls',[d;L]');
%csvwrite('results.csv',[d;L]');
%wk1write('results.wk1',[d;L]');
%save results.mat;
%hgsave('curves.fig')
%fclose(fid);