Pārlūkot izejas kodu

add AZ/EL to plot labels (azimuth and elevation of measurement), update plot options

Fernando Pablo Lopez-Lezcano 7 gadi atpakaļ
vecāks
revīzija
b5fbb7ce54
1 mainītis faili ar 36 papildinājumiem un 21 dzēšanām
  1. 36 21
      calibration/src/sphear_bf_plot_frequency_response.m

+ 36 - 21
calibration/src/sphear_bf_plot_frequency_response.m

@@ -5,7 +5,7 @@
 %% sphear_bf_plot_frequency_response: plot frequency response of B-Format signals
 %%
 %% usage:
-%%   [] = sphear_bf_plot_frequency_response(BF, frefmin, frefmax, fmin, fmax, ymin, ymax, FS, fft_size, smooth)
+%%   [] = sphear_bf_plot_frequency_response(BF, AZ, EL, frefmin, frefmax, fmin, fmax, ymin, ymax, FS, fft_size, smooth)
 %%
 %% BF: B-Format signals for each measurement
 %% frefmin, frefmax: reference frequency range to normalize W to 0dB
@@ -18,7 +18,7 @@
 %%
 %% smooth: number of samples to average, default is 0
 %%
-%% Copyright 2016-2017, Fernando Lopez-Lezcano, All Rights Reserved
+%% Copyright 2016-2018, Fernando Lopez-Lezcano, All Rights Reserved
 %% nando@ccrma.stanford.edu
 %%
 %%  This program is free software: you can redistribute it and/or modify
@@ -34,7 +34,7 @@
 %%  You should have received a copy of the GNU General Public License
 %%  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-function [] = sphear_bf_plot_frequency_response(BF, frefmin, frefmax, fmin, fmax, ymin, ymax, FS, fft_size, figure_title, smooth)
+function [] = sphear_bf_plot_frequency_response(BF, AZ, EL, frefmin, frefmax, fmin, fmax, ymin, ymax, FS, fft_size, smooth)
   %% no smoothing by default
   if (!exist("smooth"))
     smooth = 0;
@@ -52,38 +52,53 @@ function [] = sphear_bf_plot_frequency_response(BF, frefmin, frefmax, fmin, fmax
       end
     end
   end
+  %% decide which components to plot based on size of array
+  b_size = size(BF,2);
   %% plot frequency responses for each measurement
   for m = 1:size(BF, 1)
     fig = figure;
     hold on;
     fr = (1:fft_size/2) * FS/fft_size;
     grid on;
-    angle = 360 / 16 * (m - 1);
-    if (exist("figure_title"))
-      title([figure_title sprintf(" azimuth = %.1f degrees", angle)]);
-    end
+    title(sprintf(" azimuth = %.1f, elevation = %.1f (degrees)", AZ(m)/pi*180, EL(m)/pi*180));
     axis([fmin, fmax, ymin, ymax]);
     tics('y', [9, 6, 3, 0, -3, -6, -9, -12, -15, -20, -25, -30, -40, -50]);
     tics('x', [300, 500, 1000, 2000, 3000, 5000, 7000, 10000, 15000, 20000]);
     ca=get(gcf, "currentaxes");
-    set(ca, "fontweight", "bold", "linewidth", 1.5);
+    set(ca, "fontweight", "bold", "linewidth", 1.0);
     pbaspect([16, 9, 1]);
-    semilogx(fr, bfft(m,1,1:end/2), 'k;W;', "linewidth", 1.5);
-    semilogx(fr, bfft(m,2,1:end/2), 'r;X;', "linewidth", 1.5);
-    semilogx(fr, bfft(m,3,1:end/2), 'b;Y;', "linewidth", 1.5);
-    semilogx(fr, bfft(m,4,1:end/2), 'g;Z;', "linewidth", 1.5);
-    if (size(BF, 2) > 4)
-      semilogx(fr, bfft(m,5,1:end/2), 'c:;S;', "linewidth", 1.5);
-      semilogx(fr, bfft(m,6,1:end/2), 'm:;T;', "linewidth", 1.5);
-      semilogx(fr, bfft(m,7,1:end/2), 'r--;U;', "linewidth", 1.5);
-      semilogx(fr, bfft(m,8,1:end/2), 'b--;V;', "linewidth", 1.5);
-      l = legend('W', 'X', 'Y', 'Z', 'S', 'T', 'U', 'V');
-    else
+    if (b_size == 4)
+      %% WXYZ
+      semilogx(fr, bfft(m,1,1:end/2), 'k;W;', "linewidth", 1.25);
+      semilogx(fr, bfft(m,2,1:end/2), 'r;X;', "linewidth", 1.25);
+      semilogx(fr, bfft(m,3,1:end/2), 'b;Y;', "linewidth", 1.25);
+      semilogx(fr, bfft(m,4,1:end/2), 'g;Z;', "linewidth", 1.25);
       l = legend('W', 'X', 'Y', 'Z');
     end
-    legend(l, 'location', 'westoutside');
+    if (b_size == 5)
+      %% WXYUV (second order horizontal)
+      semilogx(fr, bfft(m,1,1:end/2), 'k;W;', "linewidth", 1.25);
+      semilogx(fr, bfft(m,2,1:end/2), 'r;X;', "linewidth", 1.25);
+      semilogx(fr, bfft(m,3,1:end/2), 'b;Y;', "linewidth", 1.25);
+      semilogx(fr, bfft(m,4,1:end/2), 'r--;U;', "linewidth", 1.25);
+      semilogx(fr, bfft(m,5,1:end/2), 'b--;V;', "linewidth", 1.25);
+      l = legend('W', 'X', 'Y', 'U', 'V');
+    end
+    if (b_size > 5)
+      %% WXYZSTUV (second order full sphere)
+      semilogx(fr, bfft(m,1,1:end/2), 'k;W;', "linewidth", 1.25);
+      semilogx(fr, bfft(m,2,1:end/2), 'r;X;', "linewidth", 1.25);
+      semilogx(fr, bfft(m,3,1:end/2), 'b;Y;', "linewidth", 1.25);
+      semilogx(fr, bfft(m,4,1:end/2), 'g;Z;', "linewidth", 1.25);
+      semilogx(fr, bfft(m,5,1:end/2), 'r:;S;', "linewidth", 1.25);
+      semilogx(fr, bfft(m,6,1:end/2), 'b:;T;', "linewidth", 1.25);
+      semilogx(fr, bfft(m,7,1:end/2), 'r--;U;', "linewidth", 1.25);
+      semilogx(fr, bfft(m,8,1:end/2), 'b--;V;', "linewidth", 1.25);
+      l = legend('W', 'X', 'Y', 'Z', 'S', 'T', 'U', 'V');
+    end
+    legend(l, 'location', 'west');
     hold off;
     %% write file with eps plot
-    print(fig, '-deps', '-tight', '-color', ["../data/current/figures/sphear_bf_azimuth_" sprintf("%03.0f", angle) ".eps"]);
+    %% print(fig, '-deps', '-tight', '-color', ["../data/current/figures/sphear_bf_azimuth_" sprintf("%03.0f", angle) ".eps"]);
   end
 end