diff m-toolbox/classes/@parfrac/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/@parfrac/fromPzmodel.m	Wed Nov 23 19:22:13 2011 +0100
@@ -0,0 +1,76 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% FUNCTION:    fromPzmodel
+%
+% DESCRIPTION: Construct a parfrac from a pzmodel
+%
+% CALL:        r = fromPzmodel(a, pl)
+%
+% PARAMETER:   pl   - plist
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+function r = fromPzmodel(r, pli)
+  
+  VERSION = '$Id: fromPzmodel.m,v 1.15 2011/08/15 12:31:51 hewitson Exp $';
+  
+  
+  % get pzmodel info
+  ii = parfrac.getInfo('parfrac', 'From Pzmodel');
+  
+  % Set the method version string in the minfo object
+  ii.setMversion([VERSION '-->' ii.mversion]);
+  
+  % Combine input plist with default values
+  pl = applyDefaults(ii.plists, pli);
+  
+  % Set fields
+  pzm = find(pl, 'pzmodel');
+  
+  %--- Convert to parfrac
+  
+  ps = [];
+  zs = [];
+  if ~isempty(pzm.poles(:))
+    ps = vertcat(pzm.poles(:).ri);
+  end
+  if ~isempty(pzm.zeros(:))
+    zs = vertcat(pzm.zeros(:).ri);
+  end
+  
+  % get math gain out of the pzmodel
+  gs = utils.math.getk(zs,ps,pzm.gain);
+  [res, poles, dterms, pmul] = utils.math.cpf('INOPT', 'PZ', ...
+    'POLES', ps, ...
+    'ZEROS', zs, ...
+    'GAIN', gs, ...
+    'MODE', 'SYM');
+  
+  r.res = res;
+  r.poles = poles;
+  r.pmul = pmul;
+  r.dir = dterms;
+  
+  % Set other properties
+  if isempty(pl.find('ounits'))
+    pl.pset('ounits', pzm.ounits);
+  end
+  
+  if isempty(pl.find('iunits'))
+    pl.pset('iunits', pzm.iunits);
+  end
+  
+  if isempty(pl.find('name'))
+    pl.pset('name', sprintf('parfrac(%s)', pzm.name));
+  end
+  
+  if isempty(pl.find('description'))
+    pl.pset('description', pzm.description);
+  end
+  
+  % Add history
+  r.addHistory(ii, pl, [], pzm.hist);
+  
+  % Set object properties
+  r.setObjectProperties(pl);
+  
+end