Ver código fonte

return sampling rate, remove Fs from parameters

Fernando Pablo Lopez-Lezcano 10 anos atrás
pai
commit
45414cb733
1 arquivos alterados com 16 adições e 8 exclusões
  1. 16 8
      sphear_a2b_all.m

+ 16 - 8
sphear_a2b_all.m

@@ -4,17 +4,20 @@
 %% sphear_a2b_all: calculate A2B matrixes for frequency ranges
 %%
 %% usage:
-%%   [F FE A2BF] = sphear_a2b_all(m, fmin, fmax, Noct, Fs, Nsamp, Npre, plt)
+%%   [F FE A2BF Fs] = sphear_a2b_all(m, fmin, fmax, Noct, Nsamp, Npre, plot_on)
 %%
 %% m: vector of measurement numbers to take into account
 %% fmin, fmax: lower and upper frequency limits
 %% Noct: width of frequency ranges in fractions of an octave, this
 %%       will be changed slightly so that the frequency range is
 %%       covered by equally spaced frequency bands
-%% Fs: sampling rate
-%% Nsamp: time domain samples to use
+%% Nsamp: total number of time domain samples to use
 %% Npre: samples to use before the main impulse peak
 %%
+%% optional parameters:
+%%
+%% dplot: plot polar response for each frequency band (default is 0)
+%%
 %% Copyright 2016, Fernando Lopez-Lezcano, All Rights Reserved
 %% nando@ccrma.stanford.edu
 %%
@@ -31,7 +34,12 @@
 %%  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 [F FE A2BF PVF] = sphear_a2b_all(m, fmin, fmax, Noct, Fs, Nsamp, Npre, plt)
+function [F FE Fs A2BF PVF] = sphear_a2b_all(m, fmin, fmax, Noct, Nsamp, Npre, plot_on)
+
+  %% do not plot by default
+  if (!exist("plot_on"))
+    plot_on = 0;
+  end
 
   A2BF = zeros(1, 4, 4);
 
@@ -48,21 +56,21 @@ function [F FE A2BF PVF] = sphear_a2b_all(m, fmin, fmax, Noct, Fs, Nsamp, Npre,
   fe = fmin * 2.^((0:n)/N)';
   
   for i = (1:size(fc))
-    R = sphear_af_power(m, fe(i), fe(i + 1), Nsamp, Npre, 1.1);
+    [R srate] = sphear_af_power(m, fe(i), fe(i + 1), Nsamp, Npre, 1.1);
     [A2B pv max_err] = A2B_matrix(R);
-    %% measurement, b format component, capsule
     A2BF(i,:,:) = A2B;
     PVF(i,:,:) = pv;
     BF = R * A2B;
 
-    printf("%d: %d -> [%d %d] cond=%f\n", i, fc(i), fe(i), fe(i + 1), cond(A2B));
+    printf("%2d: %5d -> [%5d %5d] A2B cond=%f\n", i, fc(i), fe(i), fe(i + 1), cond(A2B));
 
-    if plt
+    if plot_on
       sphear_bf_plot(BF, fe(i), fe(i + 1), 1.1);
     end
   end
 
   F = fc;
   FE = fe;
+  Fs = srate;
 end