diff m-toolbox/classes/@mfir/fromPzmodel.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/@mfir/fromPzmodel.m	Wed Nov 23 19:22:13 2011 +0100
@@ -0,0 +1,58 @@
+% Construct an mfir from a pzmodel
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% FUNCTION:    fromPzmodel
+%
+% DESCRIPTION: Construct an mfir from a pzmodel
+%
+% CALL:        f = fromPzmodel(f, pli)
+%
+% PARAMETER:   type:     String with filter type description
+%              pli:       Parameter list object
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+function f = fromPzmodel(f, pli)
+  
+  VERSION = '$Id: fromPzmodel.m,v 1.15 2011/08/15 11:43:01 hewitson Exp $';
+  ii = mfir.getInfo('mfir', 'From Pzmodel');
+  % Set the method version string in the minfo object
+  ii.setMversion([VERSION '-->' ii.mversion]);
+  
+  % Add default values
+  pl = applyDefaults(ii.plists, pli);
+  
+  % Get parameters
+  pzm = find(pl, 'pzmodel');
+  fs  = find(pl, 'fs');
+  
+  if isempty(fs)
+    % get max freq in pzmodel
+    fs = 8*getupperFreq(pzm);
+    warning([sprintf('!!! no sample rate specified. Designing for fs=%2.2f Hz.', fs)...
+      sprintf('\nThe filter will be redesigned later when used.')]);
+  end
+  % make MIIR filter
+  f = tomfir(pzm, plist('fs', fs));
+  
+  % override default input plist values
+  if isempty(pl.find('name'))
+    pl.pset('name', sprintf('fir(%s)', pzm.name));
+  end
+  if isempty(pl.find('description'))
+    pl.pset('description', pzm.description);
+  end
+  if isempty(pl.find('iunits'))
+    pl.pset('iunits', pzm.iunits);
+  end
+  if isempty(pl.find('ounits'))
+    pl.pset('ounits', pzm.ounits);
+  end
+  
+  % Add history
+  f.addHistory(ii, pl, [], pzm.hist);
+  
+  % Set remaining properties
+  f.setObjectProperties(pl);
+  
+end % End fromPzmodel