%COLDEX antenna measurement on Basler after install on Dec 5, 2023

%% Fuselage H
figure(1); clf;
h_plot = [];
legend_strs = {};
ant = 1:16;
for ant_idx = 1:length(ant)
  fn = sprintf('COLDEX_FUSELAGE_INSTALLED_%dH.s1p',ant(ant_idx));
  [freq, data] = SXPParse(fn);
  S11 = squeeze(data(1,1,:));
  legend_strs{ant_idx} = sprintf('ANT %dH',ant(ant_idx));

  h_plot(ant_idx) = plot(freq/1e6,lp(S11));
  hold on;

  grid on;
  xlabel('Frequency (MHz)')
  ylabel('Return loss (dB)')
end
legend(h_plot, legend_strs, 'location', 'best')
xlim([500 1000]);
saveas(1,'fuselageH.fig');
saveas(1,'fuselageH.png');

%% Fuselage V
% figure(2); clf;
% h_plot = [];
% legend_strs = {};
% ant = [1:4 13:16];
% for ant_idx = 1:length(ant)
%   fn = sprintf('COLDEX_FUSELAGE_INSTALLED_%dV.s1p',ant(ant_idx));
%   [freq, data] = SXPParse(fn);
%   S11 = squeeze(data(1,1,:));
%   legend_strs{ant_idx} = sprintf('ANT %dV',ant(ant_idx));
% 
%   h_plot(ant_idx) = plot(freq/1e6,lp(S11));
%   hold on;
% 
%   grid on;
%   xlabel('Frequency (MHz)')
%   ylabel('Return loss (dB)')
% end
% legend(h_plot, legend_strs, 'location', 'best')
% xlim([500 1000]);

%% Wing H
figure(3); clf;
h_plot = [];
legend_strs = {};
ant = [1:6];
for ant_idx = 1:length(ant)
  fn = sprintf('COLDEX_WING_INSTALLED_%d.s1p',ant(ant_idx));
  [freq, data] = SXPParse(fn);
  S11 = squeeze(data(1,1,:));
  legend_strs{ant_idx} = sprintf('ANT %dW',ant(ant_idx));

  h_plot(ant_idx) = plot(freq/1e6,lp(S11));
  hold on;

  grid on;
  xlabel('Frequency (MHz)')
  ylabel('Return loss (dB)')
end
legend(h_plot, legend_strs, 'location', 'best')
xlim([500 1000]);
saveas(3,'wing.fig');
saveas(3,'wing.png');


%% UTIG
figure(4); clf;
h_plot = [];
legend_strs = {};
ant = {'LH','RH'};
for ant_idx = 1:length(ant)
  fn = sprintf('UTIG_%s.s1p',ant{ant_idx});
  [freq, data] = SXPParse(fn);
  S11 = squeeze(data(1,1,:));
  legend_strs{ant_idx} = sprintf('ANT %s',ant{ant_idx});

  h_plot(ant_idx) = plot(freq/1e6,lp(S11));
  hold on;

  grid on;
  xlabel('Frequency (MHz)')
  ylabel('Return loss (dB)')
end
legend(h_plot, legend_strs, 'location', 'best')
xlim([50 1000]);
saveas(4,'utig.fig');
saveas(4,'utig.png');


