function [modelC, RR, testC] = regionsC( param )
load('Cell_Info');
RR = zeros(203, 203); na = zeros(1,3); nb = zeros(1,3); n = zeros(1,3);
testC = Cell_Info_C;
modelC = Cell_Info_G;
for i = 1:203
for j = 1:203
if Cell_Info_C.ReceivedPowerMap(i,j) == 0
testC.ReceivedPowerMap(i,j) = 0;
elseif Cell_Info_C.ReceivedPowerMap(i,j) < -90
testC.ReceivedPowerMap(i,j) = 1;
elseif Cell_Info_C.ReceivedPowerMap(i,j) < -88
testC.ReceivedPowerMap(i,j) = 2;
elseif Cell_Info_C.ReceivedPowerMap(i,j) < -85
testC.ReceivedPowerMap(i,j) = 3;
elseif Cell_Info_C.ReceivedPowerMap(i,j) < -80
testC.ReceivedPowerMap(i,j) = 4;
elseif Cell_Info_C.ReceivedPowerMap(i,j) < -75
testC.ReceivedPowerMap(i,j) = 5;
elseif Cell_Info_C.ReceivedPowerMap(i,j) < -60
testC.ReceivedPowerMap(i,j) = 6;
elseif Cell_Info_C.ReceivedPowerMap(i,j) < -55
testC.ReceivedPowerMap(i,j) = 7;
else
testC.ReceivedPowerMap(i,j) = 8;
end
end
end
for i = 1:203
for j = 1:203
R = sqrt((101-i)^2 + (101-j)^2)*10;
if R == 0
R = 5;
end
PL = Cell_Info_C.erp - Cell_Info_C.ReceivedPowerMap(i,j) + 20*log10((3*10^8/(850*10^6))/(4*pi));
ang = atan2(i-101,j-101)*180/pi;
if ang < 0
ang = ang + 360;
end
if 72 <= ang && ang <= 182
if Cell_Info_C.ReceivedPowerMap(i,j) ~= 0
na(1) = na(1) + PL*10*log10(R);
nb(1) = nb(1) + (10*log10(R))^2;
end
RR(i,j) = 1;
elseif 42 < ang && ang < 72
if Cell_Info_C.ReceivedPowerMap(i,j) ~= 0
na(2) = na(2) + PL*10*log10(R);
nb(2) = nb(2) + (10*log10(R))^2;
end
RR(i,j) = 2;
elseif 182 < ang && ang < 222
if Cell_Info_C.ReceivedPowerMap(i,j) ~= 0
na(2) = na(2) + PL*10*log10(R);
nb(2) = nb(2) + (10*log10(R))^2;
end
RR(i,j) = 2;
else
if Cell_Info_C.ReceivedPowerMap(i,j) ~= 0
na(3) = na(3) + PL*10*log10(R);
nb(3) = nb(3) + (10*log10(R))^2;
end
RR(i,j) = 3;
end
end
end
for i = 1:203
for j = 1:203
R = sqrt((101-i)^2 + (101-j)^2)*10;
if RR(i,j) == 1
if testC.ReceivedPowerMap(i,j) > 6
testC.ReceivedPowerMap(i,j) = testC.ReceivedPowerMap(i,j) + 2;
elseif testC.ReceivedPowerMap(i,j) > 0
testC.ReceivedPowerMap(i,j) = testC.ReceivedPowerMap(i,j) + 1;
end
elseif RR(i,j) == 2
if testC.ReceivedPowerMap(i,j) > 6
testC.ReceivedPowerMap(i,j) = testC.ReceivedPowerMap(i,j) + 1;
end
else
if testC.ReceivedPowerMap(i,j) > 4
testC.ReceivedPowerMap(i,j) = testC.ReceivedPowerMap(i,j) - 1;
end
end
end
end
n = na ./ nb
for i = 1:203
for j = 1:203
R = sqrt((101-i)^2 + (101-j)^2)*10;
region = testC.ReceivedPowerMap(i,j);
if R ~= 0
if RR(i,j) == 1
if region == 1
PL = 46.3 + 33.9*log10(850*10^6)-13.82*log(220)+(44.9-6.55*log(220))*log10(R) + 15;
elseif region == 2
PL = 46.3 + 33.9*log10(850*10^6)-13.82*log(220)+(44.9-6.55*log(220))*log10(R) + 3;
elseif region == 3
PL = 46.3 + 33.9*log10(850*10^6)-13.82*log(220)+(44.9-6.55*log(220))*log10(R) + 3;
elseif region == 4
PL = 46.3 + 33.9*log10(850*10^6)-13.82*log(220)+(44.9-6.55*log(220))*log10(R) - 7;
elseif region == 5
PL = 46.3 + 33.9*log10(850*10^6)-13.82*log(220)+(44.9-6.55*log(220))*log10(R) - 12;
elseif region == 6
PL = 46.3 + 33.9*log10(850*10^6)-13.82*log(220)+(44.9-6.55*log(220))*log10(R) - 26;
elseif region == 7
PL = 46.3 + 33.9*log10(850*10^6)-13.82*log(220)+(44.9-6.55*log(220))*log10(R) - 32;
else
PL = 46.3 + 33.9*log10(850*10^6)-13.82*log(220)+(44.9-6.55*log(220))*log10(R) - 34;
end
if testC.ReceivedPowerMap(i,j) ~= 0
modelC.ReceivedPowerMap(i,j) = modelC.erp + 20*log10((3*10^8/(850*10^6))/(4*pi)) - PL+ 210.5;
else
modelC.ReceivedPowerMap(i,j) = modelC.erp + 20*log10((3*10^8/(850*10^6))/(4*pi)) - 10*n(1)*log10(R);
end
elseif RR(i,j) == 2
if region == 1
PL = 46.3 + 33.9*log10(850*10^6)-13.82*log(220)+(44.9-6.55*log(220))*log10(R) + 2;
elseif region == 2
PL = 46.3 + 33.9*log10(850*10^6)-13.82*log(220)+(44.9-6.55*log(220))*log10(R) + 2;
elseif region == 3
PL = 46.3 + 33.9*log10(850*10^6)-13.82*log(220)+(44.9-6.55*log(220))*log10(R) - 0;
elseif region == 4
PL = 46.3 + 33.9*log10(850*10^6)-13.82*log(220)+(44.9-6.55*log(220))*log10(R) - 2;
elseif region == 5
PL = 46.3 + 33.9*log10(850*10^6)-13.82*log(220)+(44.9-6.55*log(220))*log10(R) - 4;
elseif region == 6
PL = 46.3 + 33.9*log10(850*10^6)-13.82*log(220)+(44.9-6.55*log(220))*log10(R) - 12;
elseif region == 7
PL = 46.3 + 33.9*log10(850*10^6)-13.82*log(220)+(44.9-6.55*log(220))*log10(R) - 18;
else
PL = 46.3 + 33.9*log10(850*10^6)-13.82*log(220)+(44.9-6.55*log(220))*log10(R) - 20;
end
if testC.ReceivedPowerMap(i,j) ~= 0
modelC.ReceivedPowerMap(i,j) = modelC.erp + 20*log10((3*10^8/(850*10^6))/(4*pi)) - PL+ 210.5;
else
modelC.ReceivedPowerMap(i,j) = modelC.erp + 20*log10((3*10^8/(850*10^6))/(4*pi)) - 10*n(2)*log10(R);
end
elseif RR(i,j) == 3
if region == 1
PL = 46.3 + 33.9*log10(850*10^6)-13.82*log(220)+(44.9-6.55*log(220))*log10(R) + 13;
elseif region == 2
PL = 46.3 + 33.9*log10(850*10^6)-13.82*log(220)+(44.9-6.55*log(220))*log10(R) + 6;
elseif region == 3
PL = 46.3 + 33.9*log10(850*10^6)-13.82*log(220)+(44.9-6.55*log(220))*log10(R) + 3;
elseif region == 4
PL = 46.3 + 33.9*log10(850*10^6)-13.82*log(220)+(44.9-6.55*log(220))*log10(R) - 1;
elseif region == 5
PL = 46.3 + 33.9*log10(850*10^6)-13.82*log(220)+(44.9-6.55*log(220))*log10(R) - 6;
elseif region == 6
PL = 46.3 + 33.9*log10(850*10^6)-13.82*log(220)+(44.9-6.55*log(220))*log10(R) - 15;
elseif region == 7
PL = 46.3 + 33.9*log10(850*10^6)-13.82*log(220)+(44.9-6.55*log(220))*log10(R) - 25;
else
PL = 46.3 + 33.9*log10(850*10^6)-13.82*log(220)+(44.9-6.55*log(220))*log10(R) - 32;
end
if R < 50
PL = PL + 10;
end
if testC.ReceivedPowerMap(i,j) ~= 0
modelC.ReceivedPowerMap(i,j) = modelC.erp + 20*log10((3*10^8/(850*10^6))/(4*pi)) - PL+ 221.5;
else
modelC.ReceivedPowerMap(i,j) = modelC.erp + 20*log10((3*10^8/(850*10^6))/(4*pi)) - 10*n(3)*log10(R);
end
end
end
end
end
save actualA.mat Cell_Info_C;
Cell_Info_C = modelC;
save modelC.mat Cell_Info_C;
CompareMaps('actualA', 'modelC')