diff m-toolbox/classes/@miir/fromAB.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/classes/@miir/fromAB.m	Wed Nov 23 19:22:13 2011 +0100
@@ -0,0 +1,59 @@
+% Construct an miir from coefficients
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% FUNCTION:    fromAB
+%
+% DESCRIPTION: Construct an miir from coefficients
+%
+% CALL:        f = fromAB(f, pli)
+%
+% PARAMETER:   pli: Parameter list object
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+function f = fromAB(f, pli)
+  
+  ii = miir.getInfo('miir', 'From AB');
+  % Set the method version string in the minfo object
+  ii.setMversion(['$Id: fromAB.m,v 1.22 2011/09/15 11:50:05 hewitson Exp $-->' ii.mversion]);
+  
+  % Add default values
+  pl = applyDefaults(ii.plists, pli);
+  
+  a  = find(pl, 'a');
+  b  = find(pl, 'b');
+  fs = find(pl, 'fs');
+  
+  % Checking the coefficients are listed in rows
+  if size(a,1)~=1
+    a = a';
+  end
+  if size(b,1)~=1
+    b = b';
+  end
+  
+  % Zero pad to avoid 0 length history vector
+  if numel(a) <= 1
+    a = [a 0];
+  end
+  if numel(b) <= 1
+    b = [b 0];
+  end
+  
+  f.fs      = fs;
+  f.a       = a;
+  f.b       = b;
+  f.histin  = zeros(1,f.ntaps-1);  % initialise input history
+  f.histout = zeros(1,f.ntaps-1);  % initialise output history
+  
+  if isempty(pl.find('name'))
+    pl.pset('name', 'AB');
+  end
+  
+  % Add history
+  f.addHistory(ii, pl, [], []);
+  
+  % Set object properties
+  f.setObjectProperties(pl, {'a', 'b', 'fs'});
+  
+end % End fromAB