Selaa lähdekoodia

use size of B components to decide whether to calculate UV

Fernando Pablo Lopez-Lezcano 9 vuotta sitten
vanhempi
sitoutus
5bf4006c2c
1 muutettua tiedostoa jossa 7 lisäystä ja 8 poistoa
  1. 7 8
      calibration/src/sphear_calibration_common.m

+ 7 - 8
calibration/src/sphear_calibration_common.m

@@ -267,17 +267,16 @@ function [A2B XY_gain, UV_gain] = sphear_bf_normalize_gain(A2B, B, FS, fmin, fma
   B_power = sphear_signal_power(B, FS, fmin, fmax, fft_size);
   %% W, all measurements
   W_avg = mean(B_power(:,1));
-  %% XY, first order lobes
-  XY_avg = mean([mean(B_power([1,9],2)), mean(B_power([5, 13], 3))]);
-  if (size(A2B, 1) > 4)
-    %% UV, second order lobes
-    UV_avg = mean([mean(B_power([1,5,9,13],5)), mean(B_power([3,7,11,15], 6))]);
+  %% XY, peak of first order lobes
+  XY_avg = mean([mean(B_power([1,9], 2)), mean(B_power([5, 13], 3))]);
+  if (size(A2B, 2) > 4)
+    %% UV, peak of second order lobes
+    UV_avg = mean([mean(B_power([1,5,9,13], 5)), mean(B_power([3,7,11,15], 6))]);
   end
-
-  %% now calculate the gain coefficients and normalize the A2B matrix
+  %% calculate the gain coefficients and normalize the A2B matrix
   XY_gain = XY_avg/W_avg;
   A2B(:,[2,3,4]) = A2B(:,[2,3,4]) / XY_gain;
-  if (size(A2B, 1) > 4)
+  if (size(A2B, 2) > 4)
     UV_gain = UV_avg/W_avg;
     A2B(:,[5,6]) = A2B(:,[5,6]) / UV_gain;
   else