% close all;
% clear all;

h1 = 0.8;
h2 = 1;
%r = 3;
P = 100;


% Izotropní záøiè
%D = ones(1,360);

% Dipol (shift)
%D = dipol(90);

% random
%D = rand(1, 360);

% Get_random_Char
D = get_random_Char(1)

% X = [zeros(1, 181) ones(1,180)]
% X = [ones(1,180) zeros(1, 181)]
% 
% D = X.*Dx;


%% Prijmaci antena - charky


 
% T_both = xlsread('3142_BiConiLog_97.xls'); 
%  T_ver = T_both(:,1:8);
%  T_hor = T_both(:,9:16);




%% r = 10 m

r = 10;
 i = 1;

for h2 = 1:0.05:4
   
   
    
r1 = sqrt((h2-h1)^2 + r^2);
r2 = sqrt((h1+h2)^2 + r^2);

del_r = r2 - r1;

lam = 3e8/(1000e6);
k = 2*pi/lam;



alfaD = (180/pi)*asin((h2-h1)/r1);
betaD = (180/pi)*asin((h2+h1)/r2);

Up = round(alfaD);
Uo = round(360-betaD);

Upt = round(alfaD);
Uot = round(betaD);


 E1(i) = (sqrt(30*P*D(Up))/r1);
 E2(i) = (sqrt(30*P*D(Uo))/r2);

 Ev(i) = abs( E1(i) + E2(i)*exp(j*k*del_r));
 Eh(i) = abs( E1(i) - E2(i)*exp(j*k*del_r));

  
 i = i+1;
end

 
Xplot = 1:0.05:4;
 
figure(1)

subplot(2,2,1)
plot(Xplot, Ev, 'k');
hold on;
set(gcf, 'color', [1 1 1])
set(gca,'FontSize',15)
legend('Izo', 'dipól 0','dipól 45', 'dipól 90')
title('Horizontální polarizace (10 m)');
xlabel('Výška antény');
ylabel('Intenzita [V/m]');

hold on;
subplot(2,2,3)
plot(Xplot, Eh, 'k');
hold on;
set(gcf, 'color', [1 1 1])
set(gca,'FontSize',15)
title('Vertikální polarizace (10 m)');
legend('Izo', 'dipól 0','dipól 45', 'dipól 90')
xlabel('Výška antény');
ylabel('Intenzita [V/m]');

t=(pi/180):(pi/180):2*pi;

subplot(2,2,[2,4])
polar(t,D(1, 1:360), 'k');
hold on;
set(gcf, 'color', [1 1 1])
set(gca,'FontSize',15)
title('Smerové charakteristiky');
legend('Izo', 'dipól 0','dipól 45', 'dipól 90')



        

