clear all;
close all;

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

freq1 = xlsread(filename, sheet, 'B4:B15');
freq2 = xlsread(filename, sheet, 'B15:B20');

LF_VER_F2 = xlsread(filename, sheet, 'D4:D15');
LF_VER_FS = xlsread(filename, sheet, 'E4:E15');
LF_VER_SS = xlsread(filename, sheet, 'F4:F15');

LF_HOR_F2 = xlsread(filename, sheet, 'I4:I15');
LF_HOR_FS = xlsread(filename, sheet, 'J4:J15');
LF_HOR_SS = xlsread(filename, sheet, 'K4:K15');

HF_VER_FS = xlsread(filename, sheet, 'S15:S20');
HF_VER_F1 = xlsread(filename, sheet, 'T15:T20');
HF_VER_SS = xlsread(filename, sheet, 'U15:U20');
HF_VER_S1 = xlsread(filename, sheet, 'V15:V20');

HF_HOR_FS = xlsread(filename, sheet, 'N15:N20');
HF_HOR_F1 = xlsread(filename, sheet, 'O15:O20');
HF_HOR_SS = xlsread(filename, sheet, 'P15:P20');
HF_HOR_S1 = xlsread(filename, sheet, 'Q15:Q20');

%% Make it fine

 W = window(@hann, 10);
 
 O = 1;
for Q = 1:1:length(freq1)
    for i = 1:1:7
        freq1s(O) = freq1(Q);
  
        LF_VER_F2s(O) = LF_VER_F2(Q);
        LF_VER_FSs(O) = LF_VER_FS(Q);
        LF_VER_SSs(O) = LF_VER_SS(Q);
        
        LF_HOR_F2s(O) = LF_HOR_F2(Q);
        LF_HOR_FSs(O) = LF_HOR_FS(Q);
        LF_HOR_SSs(O) = LF_HOR_SS(Q); 
       
       O = O+1;
    end
end
  
   
   freq1n = filtfilt(W, 4.5, freq1s);
   
   LF_VER_F2n = filtfilt(W, 4.5, LF_VER_F2s);
   LF_VER_FSn = filtfilt(W, 4.5, LF_VER_FSs);
   LF_VER_SSn = filtfilt(W, 4.5, LF_VER_SSs);
 
   LF_HOR_F2n = filtfilt(W, 4.5, LF_HOR_F2s);
   LF_HOR_FSn = filtfilt(W, 4.5, LF_HOR_FSs);
   LF_HOR_SSn = filtfilt(W, 4.5, LF_HOR_SSs);
   
   
    O = 1;
for Q = 1:1:length(freq2)
    for i = 1:1:7
        freq2s(O) = freq2(Q);
  
        HF_VER_FSs(O) = HF_VER_FS(Q);
        HF_VER_F1s(O) = HF_VER_F1(Q);
        HF_VER_SSs(O) = HF_VER_SS(Q);
        HF_VER_S1s(O) = HF_VER_S1(Q);
           
        HF_HOR_FSs(O) = HF_HOR_FS(Q);
        HF_HOR_F1s(O) = HF_HOR_F1(Q);
        HF_HOR_SSs(O) = HF_HOR_SS(Q);
        HF_HOR_S1s(O) = HF_HOR_S1(Q);
               
       O = O+1;
    end
end
     
   freq2n = filtfilt(W, 4.5, freq2s);
   
   HF_VER_FSn = filtfilt(W, 4.5, HF_VER_FSs);
   HF_VER_F1n = filtfilt(W, 4.5, HF_VER_F1s);
   HF_VER_SSn = filtfilt(W, 4.5, HF_VER_SSs);
   HF_VER_S1n = filtfilt(W, 4.5, HF_VER_S1s);
   
   HF_HOR_FSn = filtfilt(W, 4.5, HF_HOR_FSs);
   HF_HOR_F1n = filtfilt(W, 4.5, HF_HOR_F1s);
   HF_HOR_SSn = filtfilt(W, 4.5, HF_HOR_SSs);
   HF_HOR_S1n = filtfilt(W, 4.5, HF_HOR_S1s);
    
    
     
     
%% Results 

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

subplot(2,1,1)
plot(freq1, LF_VER_F2, 'b','LineWidth',2)
hold on;
plot(freq1, LF_VER_FS, 'r','LineWidth',2)
hold on;
plot(freq1, LF_VER_SS, 'g','LineWidth',2)

set(gca,'FontSize',25)
title('Vertikální polarizace');
legend( 'FAR (2 m)', 'FAR (sken)', 'SAR (sken)', 'Location','southeast','Orientation','horizontal')
xlabel('Frekvence [MHz]');
ylabel('Intenzita [dBuV/m]');
Xlim([30 1000])
%ylim([-2 2])
set(gca,'FontSize',20)


subplot(2,1,2)

plot(freq1, LF_VER_SS - LF_VER_F2, 'b','LineWidth',2)
hold on;
plot(freq1, LF_VER_SS - LF_VER_FS, 'r','LineWidth',2)

set(gca,'FontSize',25)
%title('Odchylka');
legend( 'FAR (2 m)', 'FAR (sken)', 'Location','southeast','Orientation','horizontal')
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(freq1n, LF_VER_F2n, 'b','LineWidth',2)
hold on;
plot(freq1n, LF_VER_FSn, 'r','LineWidth',2)
hold on;
plot(freq1n, LF_VER_SSn, 'g','LineWidth',2)

set(gca,'FontSize',25)
title('Vertikální polarizace');
legend( 'FAR (2 m)', 'FAR (sken)', 'SAR (sken)', 'Location','southeast','Orientation','horizontal')
xlabel('Frekvence [MHz]');
ylabel('Intenzita [dBuV/m]');
Xlim([30 1000])
%ylim([-2 2])
set(gca,'FontSize',20)
subplot(2,1,2)

plot(freq1n, LF_VER_SSn - LF_VER_F2n, 'b','LineWidth',2)
hold on;
plot(freq1n, LF_VER_SSn - LF_VER_FSn, 'r','LineWidth',2)

set(gca,'FontSize',25)
%title('Odchylka');
legend( 'FAR (2 m)', 'FAR (sken)', 'Location','southeast','Orientation','horizontal')
xlabel('Frekvence [MHz]');
ylabel('Odchylka [dB]');
Xlim([30 1000])
%ylim([-3 2])
set(gca,'FontSize',20)

%%

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

subplot(2,1,1)
plot(freq1, LF_HOR_F2, 'b','LineWidth',2)
hold on;
plot(freq1, LF_HOR_FS, 'r','LineWidth',2)
hold on;
plot(freq1, LF_HOR_SS, 'g','LineWidth',2)

set(gca,'FontSize',25)
title('Horizontální polarizace');
legend( 'FAR (2 m)', 'FAR (sken)', 'SAR (sken)', 'Location','southeast','Orientation','horizontal')
xlabel('Frekvence [MHz]');
ylabel('Intenzita [dBuV/m]');
Xlim([30 1000])
%ylim([-2 2])
set(gca,'FontSize',20)


subplot(2,1,2)

plot(freq1, LF_HOR_SS - LF_HOR_F2, 'b','LineWidth',2)
hold on;
plot(freq1, LF_HOR_SS - LF_HOR_FS, 'r','LineWidth',2)

set(gca,'FontSize',25)
%title('Odchylka');
legend( 'FAR (2 m)', 'FAR (sken)', 'Location','southeast','Orientation','horizontal')
xlabel('Frekvence [MHz]');
ylabel('Odchylka [dB]');
Xlim([30 1000])
%ylim([-3 2])
set(gca,'FontSize',20)


%%



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

subplot(2,1,1)
plot(freq1n, LF_HOR_F2n, 'b','LineWidth',2)
hold on;
plot(freq1n, LF_HOR_FSn, 'r','LineWidth',2)
hold on;
plot(freq1n, LF_HOR_SSn, 'g','LineWidth',2)

set(gca,'FontSize',25)
title('Horizontální polarizace');
legend( 'FAR (2 m)', 'FAR (sken)', 'SAR (sken)', 'Location','southeast','Orientation','horizontal')
xlabel('Frekvence [MHz]');
ylabel('Intenzita [dBuV/m]');
Xlim([30 1000])
%ylim([-2 2])
set(gca,'FontSize',20)
subplot(2,1,2)

plot(freq1n, LF_HOR_SSn - LF_HOR_F2n, 'b','LineWidth',2)
hold on;
plot(freq1n, LF_HOR_SSn - LF_HOR_FSn, 'r','LineWidth',2)

set(gca,'FontSize',25)
%title('Odchylka');
legend( 'FAR (2 m)', 'FAR (sken)', 'Location','southeast','Orientation','horizontal')
xlabel('Frekvence [MHz]');
ylabel('Odchylka [dB]');
Xlim([30 1000])
%ylim([-3 2])
set(gca,'FontSize',20)

%%

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

subplot(2,1,1)
plot(freq2, HF_VER_FS, 'b','LineWidth',2)
hold on;
plot(freq2, HF_VER_F1, '--b','LineWidth',2)
hold on;
plot(freq2, HF_VER_SS, 'r','LineWidth',2)
hold on;
plot(freq2, HF_VER_S1, '--r','LineWidth',2)

set(gca,'FontSize',25)
title('Vertikální polarizace');
legend( 'FAR (sken)', 'FAR (1 m)', 'SAR (sken)', 'SAR (1 m)','Location','southeast','Orientation','horizontal')
xlabel('Frekvence [MHz]');
ylabel('Intenzita [dBuV/m]');
Xlim([1000 6000])
%ylim([-2 2])
set(gca,'FontSize',20)


subplot(2,1,2)

plot(freq2, HF_VER_FS - HF_VER_F1, 'b','LineWidth',2)
hold on;
plot(freq2, HF_VER_SS - HF_VER_S1, 'r','LineWidth',2)

set(gca,'FontSize',25)
%title('Odchylka');
legend( 'FAR', 'SAR' , 'Location','southeast','Orientation','horizontal')
xlabel('Frekvence [MHz]');
ylabel('Odchylka [dB]');
Xlim([1000 6000])
%ylim([-3 2])
set(gca,'FontSize',20)


%%

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

subplot(2,1,1)
plot(freq2n, HF_VER_FSn, 'b','LineWidth',2)
hold on;
plot(freq2n, HF_VER_F1n, '--b','LineWidth',2)
hold on;
plot(freq2n, HF_VER_SSn, 'r','LineWidth',2)
hold on;
plot(freq2n, HF_VER_S1n, '--r','LineWidth',2)

set(gca,'FontSize',25)
title('Vertikální polarizace');
legend( 'FAR (sken)', 'FAR (1 m)', 'SAR (sken)', 'SAR (1 m)','Location','southeast','Orientation','horizontal')
xlabel('Frekvence [MHz]');
ylabel('Intenzita [dBuV/m]');
Xlim([1000 6000])
%ylim([-2 2])
set(gca,'FontSize',20)


subplot(2,1,2)

plot(freq2n, HF_VER_FSn - HF_VER_F1n, 'b','LineWidth',2)
hold on;
plot(freq2n, HF_VER_SSn - HF_VER_S1n, 'r','LineWidth',2)

set(gca,'FontSize',25)
%title('Odchylka');
legend( 'FAR', 'SAR' , 'Location','southeast','Orientation','horizontal')
xlabel('Frekvence [MHz]');
ylabel('Odchylka [dB]');
Xlim([1000 6000])
%ylim([-3 2])
set(gca,'FontSize',20)
%%

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

subplot(2,1,1)
plot(freq2, HF_HOR_FS, 'b','LineWidth',2)
hold on;
plot(freq2, HF_HOR_F1, '--b','LineWidth',2)
hold on;
plot(freq2, HF_HOR_SS, 'r','LineWidth',2)
hold on;
plot(freq2, HF_HOR_S1, '--r','LineWidth',2)

set(gca,'FontSize',25)
title('Horizontální polarizace');
legend( 'FAR (sken)', 'FAR (1 m)', 'SAR (sken)', 'SAR (1 m)','Location','southeast','Orientation','horizontal')
xlabel('Frekvence [MHz]');
ylabel('Intenzita [dBuV/m]');
Xlim([1000 6000])
%ylim([-2 2])
set(gca,'FontSize',20)


subplot(2,1,2)

plot(freq2, HF_HOR_FS - HF_HOR_F1, 'b','LineWidth',2)
hold on;
plot(freq2, HF_HOR_SS - HF_HOR_S1, 'r','LineWidth',2)

set(gca,'FontSize',25)
%title('Odchylka');
legend( 'FAR', 'SAR' , 'Location','southeast','Orientation','horizontal')
xlabel('Frekvence [MHz]');
ylabel('Odchylka [dB]');
Xlim([1000 6000])
%ylim([-3 2])
set(gca,'FontSize',20)


%%

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

subplot(2,1,1)
plot(freq2n, HF_HOR_FSn, 'b','LineWidth',2)
hold on;
plot(freq2n, HF_HOR_F1n, '--b','LineWidth',2)
hold on;
plot(freq2n, HF_HOR_SSn, 'r','LineWidth',2)
hold on;
plot(freq2n, HF_HOR_S1n, '--r','LineWidth',2)

set(gca,'FontSize',25)
title('Horizontální polarizace');
legend( 'FAR (sken)', 'FAR (1 m)', 'SAR (sken)', 'SAR (1 m)','Location','southeast','Orientation','horizontal')
xlabel('Frekvence [MHz]');
ylabel('Intenzita [dBuV/m]');
Xlim([1000 6000])
%ylim([-2 2])
set(gca,'FontSize',20)


subplot(2,1,2)

plot(freq2n, HF_HOR_FSn - HF_HOR_F1n, 'b','LineWidth',2)
hold on;
plot(freq2n, HF_HOR_SSn - HF_HOR_S1n, 'r','LineWidth',2)

set(gca,'FontSize',25)
%title('Odchylka');
legend( 'FAR', 'SAR' , 'Location','southeast','Orientation','horizontal')
xlabel('Frekvence [MHz]');
ylabel('Odchylka [dB]');
Xlim([1000 6000])
%ylim([-3 2])
set(gca,'FontSize',20)
%%
