view m-toolbox/classes/@rational/fromParfrac.m @ 44:409a22968d5e default

Add unit tests
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Tue, 06 Dec 2011 18:42:11 +0100
parents f0afece42f48
children
line wrap: on
line source

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% FUNCTION:    fromParfrac
%
% DESCRIPTION: Construct a rational from parfrac model
%
% CALL:        r = Parfrac(a, pl)
%
% PARAMETER:   pl   - plist
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function r = fromParfrac(r, pli)

  VERSION = '$Id: fromParfrac.m,v 1.10 2011/08/15 12:41:52 hewitson Exp $';


  % get pzmodel info
  ii = rational.getInfo('rational', 'From Parfrac');

  % 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);
  
  % Extrac model
  
  pf = find(pl, 'parfrac');
  [a,b] = residue(pf.res,pf.poles,pf.dir);
  
  % Set fields
  r.num = a;
  r.den = b;

  % Override model properties from the parfrac object
  
  if isempty(pl.find('ounits'))
    pl.pset('ounits', pf.ounits);
  end
  
  if isempty(pl.find('iunits'))
    pl.pset('iunits', pf.iunits);
  end
    
  if isempty(pl.find('name'))
    pl.pset('name', sprintf('rational(%s)', pf.name));
  end
  
  if isempty(pl.find('description'))
    pl.pset('description', pf.description);
  end
  
  % Add history
  r.addHistory(ii, pl, [], pf.hist);

  % Set object properties
  r.setObjectProperties(pl);
  
end