%% 
clear all;
close all;

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

freq_RE1 = xlsread(filename, sheet, 'B6:B23');
freq_RE18 = xlsread(filename, sheet, 'H6:H23');
freq_RI1 = xlsread(filename, sheet, 'N6:N33');
freq_RI3 = xlsread(filename, sheet, 'T6:T29');


RE1_VP  = xlsread(filename, sheet, 'C6:C23');
RE1_VW  = xlsread(filename, sheet, 'D6:D23');
RE1_HP  = xlsread(filename, sheet, 'E6:E23');
RE1_HW  = xlsread(filename, sheet, 'F6:F23');

RE18_VP  = xlsread(filename, sheet, 'K6:K23');
RE18_VW  = xlsread(filename, sheet, 'L6:L23');
RE18_HP  = xlsread(filename, sheet, 'I6:I23');
RE18_HW  = xlsread(filename, sheet, 'J6:J23');

RI1_VP  = xlsread(filename, sheet, 'O6:O33');
RI1_VW  = xlsread(filename, sheet, 'P6:P33');
RI1_HP  = xlsread(filename, sheet, 'Q6:Q33');
RI1_HW  = xlsread(filename, sheet, 'R6:R33');

RI3_VP  = xlsread(filename, sheet, 'W6:W29');
RI3_VW  = xlsread(filename, sheet, 'X6:X29');
RI3_HP  = xlsread(filename, sheet, 'U6:U29');
RI3_HW  = xlsread(filename, sheet, 'V6:V29');


%% Make it fine

 O = 1;
for Q = 1:1:length(freq_RE1)
    for i = 1:1:7
        freq_RE1s(O) = freq_RE1(Q);
  
        RE1_VPs(O) = RE1_VP(Q);
        RE1_VWs(O) = RE1_VW(Q);
        RE1_HPs(O) = RE1_HP(Q);
        RE1_HWs(O) = RE1_HW(Q);
       
       O = O+1;
    end
end
   W = window(@hann, 10);
   
   freq_RE1n = filtfilt(W, 4.5, freq_RE1s);
   
   RE1_VPn = filtfilt(W, 4.5, RE1_VPs);
   RE1_VWn = filtfilt(W, 4.5, RE1_VWs);
   RE1_HPn = filtfilt(W, 4.5, RE1_HPs);
   RE1_HWn = filtfilt(W, 4.5, RE1_HWs);
   
    O = 1;
for Q = 1:1:length(freq_RE18)
    for i = 1:1:7
        freq_RE18s(O) = freq_RE18(Q);
  
        RE18_VPs(O) = RE18_VP(Q);
        RE18_VWs(O) = RE18_VW(Q);
        RE18_HPs(O) = RE18_HP(Q);
        RE18_HWs(O) = RE18_HW(Q);
       
       O = O+1;
    end
end
     
   freq_RE18n = filtfilt(W, 4.5, freq_RE18s);
   
   RE18_VPn = filtfilt(W, 4.5, RE18_VPs);
   RE18_VWn = filtfilt(W, 4.5, RE18_VWs);
   RE18_HPn = filtfilt(W, 4.5, RE18_HPs);
   RE18_HWn = filtfilt(W, 4.5, RE18_HWs);

 O = 1;
for Q = 1:1:length(freq_RI1)
    for i = 1:1:7
        freq_RI1s(O) = freq_RI1(Q);
  
        RI1_VPs(O) = RI1_VP(Q);
        RI1_VWs(O) = RI1_VW(Q);
        RI1_HPs(O) = RI1_HP(Q);
        RI1_HWs(O) = RI1_HW(Q);
       
       O = O+1;
    end
end
   
   
   freq_RI1n = filtfilt(W, 4.5, freq_RI1s);
   
   RI1_VPn = filtfilt(W, 4.5, RI1_VPs);
   RI1_VWn = filtfilt(W, 4.5, RI1_VWs);
   RI1_HPn = filtfilt(W, 4.5, RI1_HPs);
   RI1_HWn = filtfilt(W, 4.5, RI1_HWs);
   
    O = 1;
for Q = 1:1:length(freq_RI3)
    for i = 1:1:7
        freq_RI3s(O) = freq_RI3(Q);
  
        RI3_VPs(O) = RI3_VP(Q);
        RI3_VWs(O) = RI3_VW(Q);
        RI3_HPs(O) = RI3_HP(Q);
        RI3_HWs(O) = RI3_HW(Q);
       
       O = O+1;
    end
end
 
   
   freq_RI3n = filtfilt(W, 4.5, freq_RI3s);
   
   RI3_VPn = filtfilt(W, 4.5, RI3_VPs);
   RI3_VWn = filtfilt(W, 4.5, RI3_VWs);
   RI3_HPn = filtfilt(W, 4.5, RI3_HPs);
   RI3_HWn = filtfilt(W, 4.5, RI3_HWs);

     
     
%% Results 

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

subplot(2,1,1)
plot(freq_RE1, RE1_VP, 'b','LineWidth',2)
hold on;
plot(freq_RE1, RE1_VW, 'r','LineWidth',2)

set(gca,'FontSize',25)
title('Vertikální polarizace');
legend( 'PO', 'WO', 'Location','northeast','Orientation','vertical')
xlabel('Frekvence [MHz]');
ylabel('Odchylka [dB]');
Xlim([30 1000])
%ylim([-2 2])
set(gca,'FontSize',20)

subplot(2,1,2)

plot(freq_RE1, RE1_HP, 'b','LineWidth',2)
hold on;
plot(freq_RE1, RE1_HW, 'r','LineWidth',2)

set(gca,'FontSize',25)
title('Horizontální polarizace');
legend( 'PO', 'WO', 'Location','northeast','Orientation','vertical')
xlabel('Frekvence [MHz]');
ylabel('Odchylka [dB]');
Xlim([30 1000])
%ylim([-3 2])
set(gca,'FontSize',20)

%%
figure(2)
set(gcf, 'color', [1 1 1])

subplot(2,1,1)
plot(freq_RE1n, RE1_VPn, 'b','LineWidth',2)
hold on;
plot(freq_RE1n, RE1_VWn, 'r','LineWidth',2)

set(gca,'FontSize',25)
title('Vertikální polarizace');
legend( 'PO', 'WO', 'Location','northeast','Orientation','vertical')
xlabel('Frekvence [MHz]');
ylabel('Odchylka [dB]');
Xlim([30 1000])
set(gca,'FontSize',20)

subplot(2,1,2)

plot(freq_RE1n, RE1_HPn, 'b','LineWidth',2)
hold on;
plot(freq_RE1n, RE1_HWn, 'r','LineWidth',2)

set(gca,'FontSize',25)
title('Horizontální polarizace');
legend( 'PO', 'WO', 'Location','northeast','Orientation','vertical')
xlabel('Frekvence [MHz]');
ylabel('Odchylka [dB]');
Xlim([30 1000])
set(gca,'FontSize',20)

%%

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

subplot(2,1,1)
plot(freq_RE18, RE18_VP, 'b','LineWidth',2)
hold on;
plot(freq_RE18, RE18_VW, 'r','LineWidth',2)

set(gca,'FontSize',25)
title('Vertikální polarizace');
legend( 'PO', 'WO', 'Location','northeast','Orientation','vertical')
xlabel('Frekvence [MHz]');
ylabel('Odchylka [dB]');
Xlim([1 18])
%ylim([-2 2])
set(gca,'FontSize',20)

subplot(2,1,2)

plot(freq_RE18, RE18_HP, 'b','LineWidth',2)
hold on;
plot(freq_RE18, RE18_HW, 'r','LineWidth',2)

set(gca,'FontSize',25)
title('Horizontální polarizace');
legend( 'PO', 'WO', 'Location','northeast','Orientation','vertical')
xlabel('Frekvence [MHz]');
ylabel('Odchylka [dB]');
Xlim([1 18])
%ylim([-3 2])
set(gca,'FontSize',20)

%%
figure(4)
set(gcf, 'color', [1 1 1])

subplot(2,1,1)
plot(freq_RE18n, RE18_VPn, 'b','LineWidth',2)
hold on;
plot(freq_RE18n, RE18_VWn, 'r','LineWidth',2)

set(gca,'FontSize',25)
title('Vertikální polarizace');
legend( 'PO', 'WO', 'Location','northeast','Orientation','vertical')
xlabel('Frekvence [MHz]');
ylabel('Odchylka [dB]');
Xlim([1 18])
set(gca,'FontSize',20)

subplot(2,1,2)

plot(freq_RE18n, RE18_HPn, 'b','LineWidth',2)
hold on;
plot(freq_RE18n, RE18_HWn, 'r','LineWidth',2)

set(gca,'FontSize',25)
title('Horizontální polarizace');
legend( 'PO', 'WO', 'Location','northeast','Orientation','vertical')
xlabel('Frekvence [MHz]');
ylabel('Odchylka [dB]');
Xlim([1 18])
set(gca,'FontSize',20)

%%

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

subplot(2,1,1)
plot(freq_RI1, RI1_VP, 'b','LineWidth',2)
hold on;
plot(freq_RI1, RI1_VW, 'r','LineWidth',2)

set(gca,'FontSize',25)
title('Vertikální polarizace');
legend( 'PO', 'WO', 'Location','northeast','Orientation','vertical')
xlabel('Frekvence [MHz]');
ylabel('Odchylka [dB]');
Xlim([80 1000])
%ylim([-2 2])
set(gca,'FontSize',20)

subplot(2,1,2)

plot(freq_RI1, RI1_HP, 'b','LineWidth',2)
hold on;
plot(freq_RI1, RI1_HW, 'r','LineWidth',2)

set(gca,'FontSize',25)
title('Horizontální polarizace');
legend( 'PO', 'WO', 'Location','northeast','Orientation','vertical')
xlabel('Frekvence [MHz]');
ylabel('Odchylka [dB]');
Xlim([80 1000])
%ylim([-3 2])
set(gca,'FontSize',20)

%%
figure(6)
set(gcf, 'color', [1 1 1])

subplot(2,1,1)
plot(freq_RI1n, RI1_VPn, 'b','LineWidth',2)
hold on;
plot(freq_RI1n, RI1_VWn, 'r','LineWidth',2)

set(gca,'FontSize',25)
title('Vertikální polarizace');
legend( 'PO', 'WO', 'Location','northeast','Orientation','vertical')
xlabel('Frekvence [MHz]');
ylabel('Odchylka [dB]');
Xlim([80 1000])
set(gca,'FontSize',20)

subplot(2,1,2)

plot(freq_RI1n, RI1_HPn, 'b','LineWidth',2)
hold on;
plot(freq_RI1n, RI1_HWn, 'r','LineWidth',2)

set(gca,'FontSize',25)
title('Horizontální polarizace');
legend( 'PO', 'WO', 'Location','northeast','Orientation','vertical')
xlabel('Frekvence [MHz]');
ylabel('Odchylka [dB]');
Xlim([80 1000])
set(gca,'FontSize',20)

%%

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

subplot(2,1,1)
plot(freq_RI3, RI3_VP, 'b','LineWidth',2)
hold on;
plot(freq_RI3, RI3_VW, 'r','LineWidth',2)

set(gca,'FontSize',25)
title('Vertikální polarizace');
legend( 'PO', 'WO', 'Location','northeast','Orientation','vertical')
xlabel('Frekvence [MHz]');
ylabel('Odchylka [dB]');
Xlim([1000 3000])
set(gca,'FontSize',20)

subplot(2,1,2)

plot(freq_RI3, RI3_HP, 'b','LineWidth',2)
hold on;
plot(freq_RI3, RI3_HW, 'r','LineWidth',2)

set(gca,'FontSize',25)
title('Horizontální polarizace');
legend( 'PO', 'WO', 'Location','northeast','Orientation','vertical')
xlabel('Frekvence [MHz]');
ylabel('Odchylka [dB]');
Xlim([1000 3000])
set(gca,'FontSize',20)

%%

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

subplot(2,1,1)
plot(freq_RI3n, RI3_VPn, 'b','LineWidth',2)
hold on;
plot(freq_RI3n, RI3_VWn, 'r','LineWidth',2)

set(gca,'FontSize',25)
title('Vertikální polarizace');
legend( 'PO', 'WO', 'Location','northeast','Orientation','vertical')
xlabel('Frekvence [MHz]');
ylabel('Odchylka [dB]');
Xlim([1000 3000])
set(gca,'FontSize',20)

subplot(2,1,2)

plot(freq_RI3n, RI3_HPn, 'b','LineWidth',2)
hold on;
plot(freq_RI3n, RI3_HWn, 'r','LineWidth',2)

set(gca,'FontSize',25)
title('Horizontální polarizace');
legend( 'PO', 'WO', 'Location','northeast','Orientation','vertical')
xlabel('Frekvence [MHz]');
ylabel('Odchylka [dB]');
Xlim([1000 3000])
set(gca,'FontSize',20)
