Mercurial > hg > ltpda
diff m-toolbox/classes/@parfrac/fromRational.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/fromRational.m Wed Nov 23 19:22:13 2011 +0100 @@ -0,0 +1,73 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% FUNCTION: fromRational +% +% DESCRIPTION: Construct a parfrac from a rational TF +% +% CALL: pf = fromRational(a, pl) +% +% PARAMETER: pl - plist +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +function pf = fromRational(pf, pli) + + VERSION = '$Id: fromRational.m,v 1.12 2011/08/15 12:31:59 hewitson Exp $'; + + + % get pzmodel info + ii = parfrac.getInfo('parfrac', 'From Rational'); + + % 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 + rat = find(pl, 'rational'); + + % if the denominator is not a polynomial but a single number, then the + % model is not really a rational model. It is practically a polynomial + % model and cannot be converted in partial fractions. Output PF model + % will be a zero residues and poles. Dterms will contain the numerator + % polynomial + if numel(rat.den)==1 + pf.res = 0; + pf.poles = 0; + pf.dir = (rat.num)./(rat.den); + pf.pmul = 0; + else % convert a true rational model in partial fractions + [res, poles, dterms, pmul] = utils.math.cpf('INOPT', 'RAT', ... + 'NUM', rat.num, ... + 'DEN', rat.den, 'MODE', 'SYM'); + + pf.res = res; + pf.poles = poles; + pf.dir = dterms; + pf.pmul = pmul; + end + + % Set properties from rational object + if isempty(pl.find('ounits')) + pl.pset('ounits', rat.ounits); + end + + if isempty(pl.find('iunits')) + pl.pset('iunits', rat.iunits); + end + + if isempty(pl.find('name')) + pl.pset('name', sprintf('parfrac(%s)', rat.name)); + end + + if isempty(pl.find('description')) + pl.pset('description', rat.description); + end + + % Add history + pf.addHistory(ii, pl, [], rat.hist); + + % Set object properties + pf.setObjectProperties(pl); + +end