%% Field Uniformity 
clear all;
close     all;
filename = 'matlab_data.xlsx';
sheet = 3;

%% FU - Horizontal

freq1e = xlsread(filename, sheet, 'A3:A257');
freq2e = xlsread(filename, sheet, 'A263:A374');

FU_example_LF = xlsread(filename, sheet, 'B3:Q257');
FU_example_HF = xlsread(filename, sheet, 'B263:Q374');

% 
%  O = 1;
% for Q = 1:1:length(freq1)
%       for i = 1:1:5
%         freq1es(O) = freq1e(Q);
%         FU_example_LFs(O,1) = FU_example_LF(Q,1);
%          FU_example_LFs(O,2) = FU_example_LF(Q,2);
%           FU_example_LFs(O,3) = FU_example_LF(Q,3);
%            FU_example_LFs(O,4) = FU_example_LF(Q,4);
%             FU_example_LFs(O,5) = FU_example_LF(Q,5);
%              FU_example_LFs(O,6) = FU_example_LF(Q,6);
%               FU_example_LFs(O,7) = FU_example_LF(Q,7);
%                FU_example_LFs(O,8) = FU_example_LF(Q,8);
%                 FU_example_LFs(O,9) = FU_example_LF(Q,9);
%                  FU_example_LFs(O,10) = FU_example_LF(Q,10);
%                   FU_example_LFs(O,11) = FU_example_LF(Q,11);
%                    FU_example_LFs(O,12) = FU_example_LF(Q,12);
%                     FU_example_LFs(O,13) = FU_example_LF(Q,13);
%                      FU_example_LFs(O,14) = FU_example_LF(Q,14);
%                       FU_example_LFs(O,15) = FU_example_LF(Q,15);
%                        FU_example_LFs(O,16) = FU_example_LF(Q,16);
%                        
%             
%        O = O+1;
%     end
% end
%    W = window(@hann, 10);
%    freq1en = filtfilt(W, 4.5, freq1es);
%    FU_example_LFn = filtfilt(W, 4.5, FU_example_LFs);
% 
%  O = 1;
% for Q = 1:1:length(freq2e)
%     for i = 1:1:5
%         freq2es(O) = freq2e(Q);
%        FU_example_HFs(O,1) = FU_example_HF(Q,1);
%          FU_example_HFs(O,2) = FU_example_HF(Q,2);
%           FU_example_HFs(O,3) = FU_example_HF(Q,3);
%            FU_example_HFs(O,4) = FU_example_HF(Q,4);
%             FU_example_HFs(O,5) = FU_example_HF(Q,5);
%              FU_example_HFs(O,6) = FU_example_HF(Q,6);
%               FU_example_HFs(O,7) = FU_example_HF(Q,7);
%                FU_example_HFs(O,8) = FU_example_HF(Q,8);
%                 FU_example_HFs(O,9) = FU_example_HF(Q,9);
%                  FU_example_HFs(O,10) = FU_example_HF(Q,10);
%                   FU_example_HFs(O,11) = FU_example_HF(Q,11);
%                    FU_example_HFs(O,12) = FU_example_HF(Q,12);
%                     FU_example_HFs(O,13) = FU_example_HF(Q,13);
%                      FU_example_HFs(O,14) = FU_example_HF(Q,14);
%                       FU_example_HFs(O,15) = FU_example_HF(Q,15);
%                        FU_example_HFs(O,16) = FU_example_HF(Q,16);
%             
%        O = O+1;
%     end
% end
%    W = window(@hann, 10);
%    freq2en = filtfilt(W, 4.5, freq2es);
%    FU_example_HFn = filtfilt(W, 4.5, FU_example_HFs);
%    
%    
%    figure(6)
% set(gcf, 'color', [1 1 1])
% 
% subplot(2,1,1)
% plot(freq1, FU_example_LF,'LineWidth',2)
% set(gca,'FontSize',25)
% title('Uniformita pole');
% %legend( 'H15', 'H16', 'Location','south','Orientation','horizontal')
% xlabel('Frekvence [MHz]');
% ylabel('Intenzita [V/m]');
% xlim([80 1000]);
% ylim([30 130]);
% set(gca,'FontSize',20)
% 
% subplot(2,1,2)
% plot(freq2, FU_example_HF,'LineWidth',2)
% 
% set(gca,'FontSize',25)
% title('Uniformita pole');
% %legend( 'H_Fld_15', 'H_Fld_16', 'Location','south','Orientation','horizontal')
% xlabel('Frekvence [MHz]');
% ylabel('Intenzita [V/m]');
% xlim([1000 3000]);
% ylim([5 30]);
% set(gca,'FontSize',20)
% 
% figure(7)
% set(gcf, 'color', [1 1 1])
% 
% subplot(2,1,1)
% plot(freq1en, FU_example_LFn,'LineWidth',2)
% set(gca,'FontSize',25)
% title('Uniformita pole');
% %legend( 'H15', 'H16', 'Location','south','Orientation','horizontal')
% xlabel('Frekvence [MHz]');
% ylabel('Intenzita [V/m]');
% xlim([80 1000]);
% ylim([30 130]);
% set(gca,'FontSize',20)
% 
% subplot(2,1,2)
% plot(freq2en, FU_example_HFn,'LineWidth',2)
% 
% set(gca,'FontSize',25)
% title('Uniformita pole');
% %legend( 'H_Fld_15', 'H_Fld_16', 'Location','south','Orientation','horizontal')
% xlabel('Frekvence [MHz]');
% ylabel('Intenzita [V/m]');
% xlim([1000 3000]);
% ylim([5 30]);
% set(gca,'FontSize',20)

%% FU / VER

filename = 'matlab_data.xlsx';
sheet = 4;

freq1 = xlsread(filename, sheet, 'A6:A260');
freq2 = xlsread(filename, sheet, 'B6:B58');
freq3 = xlsread(filename, sheet, 'L6:L117');


FU_LF_VF  = xlsread(filename, sheet, 'C6:C260');
FU_LF_VS0 = xlsread(filename, sheet, 'F6:F58');
FU_LF_VS4 = xlsread(filename, sheet, 'E6:E260');
FU_LF_VS9 = xlsread(filename, sheet, 'D6:D260');

FU_HF_VF  = xlsread(filename, sheet, 'M6:M117');
FU_HF_VS0 = xlsread(filename, sheet, 'P6:P117');
FU_HF_VS4 = xlsread(filename, sheet, 'O6:O117');
FU_HF_VS9 = xlsread(filename, sheet, 'N6:N117');

FU_LF_HF  = xlsread(filename, sheet, 'G6:G260');
FU_LF_HS0 = xlsread(filename, sheet, 'J6:J58');
FU_LF_HS4 = xlsread(filename, sheet, 'I6:I260');
FU_LF_HS9 = xlsread(filename, sheet, 'H6:H260');

FU_HF_HF  = xlsread(filename, sheet, 'Q6:Q117');
FU_HF_HS0 = xlsread(filename, sheet, 'T6:T117');
FU_HF_HS4 = xlsread(filename, sheet, 'S6:S117');
FU_HF_HS9 = xlsread(filename, sheet, 'R6:R117');

%% Make_it_fine func

%freq 1
 O = 1;
for Q = 1:1:length(freq1)
    for i = 1:1:5
        freq1s(O) = freq1(Q);
        FU_LF_VFs(O) = FU_LF_VF(Q);
        FU_LF_VS4s(O) = FU_LF_VS4(Q);
        FU_LF_VS9s(O) = FU_LF_VS9(Q);
        
        FU_LF_HFs(O) = FU_LF_HF(Q);
        FU_LF_HS4s(O) = FU_LF_HS4(Q);
        FU_LF_HS9s(O) = FU_LF_HS9(Q);
        
       O = O+1;
    end
end
   W = window(@hann, 10);
   
   freq1n = filtfilt(W, 4.5, freq1s);
   
   FU_LF_VFn = filtfilt(W, 4.5, FU_LF_VFs);
   FU_LF_VS4n = filtfilt(W, 4.5, FU_LF_VS4s);
   FU_LF_VS9n = filtfilt(W, 4.5, FU_LF_VS9s);
   
   FU_LF_HFn = filtfilt(W, 4.5, FU_LF_HFs);
   FU_LF_HS4n = filtfilt(W, 4.5, FU_LF_HS4s);
   FU_LF_HS9n = filtfilt(W, 4.5, FU_LF_HS9s);
   
 %freq 2
    O = 1;
for Q = 1:1:length(freq2)
    for i = 1:1:5
        freq2s(O) = freq2(Q);
        FU_LF_VS0s(O) = FU_LF_VS0(Q);
        FU_LF_HS0s(O) = FU_LF_HS0(Q);
       
       O = O+1;
    end
end
  
   freq2n = filtfilt(W, 4.5, freq2s);
   
   FU_LF_VS0n = filtfilt(W, 4.5, FU_LF_VS0s);
   FU_LF_HS0n = filtfilt(W, 4.5, FU_LF_HS0s);
  
   %freq 3
       O = 1;
for Q = 1:1:length(freq3)
    for i = 1:1:5
        freq3s(O) = freq3(Q);
        
        FU_HF_VFs(O) = FU_HF_VF(Q);
        FU_HF_VS0s(O) = FU_HF_VS0(Q);
        FU_HF_VS4s(O) = FU_HF_VS4(Q);
        FU_HF_VS9s(O) = FU_HF_VS9(Q);
        
        FU_HF_HFs(O) = FU_HF_HF(Q);
        FU_HF_HS0s(O) = FU_HF_HS0(Q);
        FU_HF_HS4s(O) = FU_HF_HS4(Q);
        FU_HF_HS9s(O) = FU_HF_HS9(Q);
              
    
       
       O = O+1;
    end
end
  
   freq3n = filtfilt(W, 4.5, freq3s);
   
   FU_HF_VFn = filtfilt(W, 4.5, FU_HF_VFs);
   FU_HF_VS0n = filtfilt(W, 4.5, FU_HF_VS0s);
   FU_HF_VS4n = filtfilt(W, 4.5, FU_HF_VS4s);
   FU_HF_VS9n = filtfilt(W, 4.5, FU_HF_VS9s);
   
   FU_HF_HFn = filtfilt(W, 4.5, FU_HF_HFs);
   FU_HF_HS0n = filtfilt(W, 4.5, FU_HF_HS0s);
   FU_HF_HS4n = filtfilt(W, 4.5, FU_HF_HS4s);
   FU_HF_HS9n = filtfilt(W, 4.5, FU_HF_HS9s);
   
   
   
%% Print results

limit = [6 6];
flim = [80 3000];
figure(8)
set(gcf, 'color', [1 1 1])

subplot(2,1,1)
plot(freq1, FU_LF_VF, 'b', 'LineWidth',2)
hold on;
plot(freq1, FU_LF_VS9,'g', 'LineWidth',2)
hold on;
plot(freq1, FU_LF_VS4,'r', 'LineWidth',2)
hold on;
plot(freq2, FU_LF_VS0,'--k', 'LineWidth',2)
hold on;


set(gca,'FontSize',25)
title('Uniformita pole - Vertikální polarizace');
legend( 'FAR', 'SAR 9', 'SAR 4', 'SAR 0', 'Location','northeast','Orientation','vertical')
xlabel('Frekvence [MHz]');
ylabel('Odchylka [dB]');
xlim([80 1000])
ylim([0 6])
set(gca,'FontSize',20)
 
subplot(2,1,2)

plot(freq3, FU_HF_VF, 'b', 'LineWidth',2)
hold on;
plot(freq3, FU_HF_VS9,'g', 'LineWidth',2)
hold on;
plot(freq3, FU_HF_VS4,'r', 'LineWidth',2)
hold on;
plot(freq3, FU_HF_VS0,'--k', 'LineWidth',2)
hold on;

set(gca,'FontSize',25)
title('Uniformita pole - Vertikální polarizace');
legend( 'FAR', 'SAR 9', 'SAR 4', 'SAR 0', 'Location','northeast','Orientation','vertical')
xlabel('Frekvence [MHz]');
ylabel('Odchylka [dB]');
xlim([1000 3000])
ylim([0 6])
set(gca,'FontSize',20)

   
figure(9)
set(gcf, 'color', [1 1 1])

subplot(2,1,1)
plot(freq1, FU_LF_HF, 'b', 'LineWidth',2)
hold on;
plot(freq1, FU_LF_HS9,'g', 'LineWidth',2)
hold on;
plot(freq1, FU_LF_HS4,'r', 'LineWidth',2)
hold on;
%plot(freq2n, FU_LF_HS0n,'--k', 'LineWidth',2)
hold on;
set(gca,'FontSize',25)
title('Uniformita pole - Horizontální polarizace');
legend( 'FAR', 'SAR 9', 'SAR 4', 'SAR 0', 'Location','northeast','Orientation','vertical')
xlabel('Frekvence [MHz]');
ylabel('Odchylka [dB]');
xlim([80 1000])
ylim([0 6])
set(gca,'FontSize',20)
 
subplot(2,1,2)
plot(freq3, FU_HF_HF, 'b', 'LineWidth',2)
hold on;
plot(freq3, FU_HF_HS9,'g', 'LineWidth',2)
hold on;
plot(freq3, FU_HF_HS4,'r', 'LineWidth',2)
hold on;
%plot(freq3n, FU_HF_HS0n,'--k', 'LineWidth',2)
hold on;
set(gca,'FontSize',25)
title('Uniformita pole - Horizontální polarizace');
legend( 'FAR', 'SAR 9', 'SAR 4', 'SAR 0', 'Location','northeast','Orientation','vertical')
xlabel('Frekvence [MHz]');
ylabel('Odchylka [dB]');
xlim([1000 3000])
ylim([0 6])
set(gca,'FontSize',20)