Mercurial > forge
changeset 8393:c41a3c1df4f6 octave-forge
control: add zpk stop-gap measure
author | paramaniac |
---|---|
date | Wed, 21 Sep 2011 20:22:37 +0000 |
parents | cf8450a5e1c8 |
children | 9ed2a6bf79f4 |
files | main/control/INDEX main/control/devel/zpk.m main/control/doc/NEWS main/control/inst/zpk.m |
diffstat | 4 files changed, 110 insertions(+), 102 deletions(-) [+] |
line wrap: on
line diff
--- a/main/control/INDEX Wed Sep 21 19:44:48 2011 +0000 +++ b/main/control/INDEX Wed Sep 21 20:22:37 2011 +0000 @@ -10,6 +10,7 @@ frd ss tf + zpk Model Data Access @lti/dssdata @lti/frdata
--- a/main/control/devel/zpk.m Wed Sep 21 19:44:48 2011 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,102 +0,0 @@ -## Copyright (C) 2011 Lukas F. Reichlin -## -## This file is part of LTI Syncope. -## -## LTI Syncope is free software: you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation, either version 3 of the License, or -## (at your option) any later version. -## -## LTI Syncope is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {Function File} {@var{s} =} zpk (@var{"s"}) -## @deftypefnx {Function File} {@var{z} =} zpk (@var{"z"}, @var{tsam}) -## @deftypefnx {Function File} {@var{sys} =} zpk (@var{sys}) -## @deftypefnx {Function File} {@var{sys} =} zpk (@var{k}) -## @deftypefnx {Function File} {@var{sys} =} zpk (@var{z}, @var{p}, @var{k}, @dots{}) -## @deftypefnx {Function File} {@var{sys} =} zpk @var{z}, @var{p}, @var{k}, @var{tsam}, @dots{}) -## @deftypefnx {Function File} {@var{sys} =} zpk (@var{z}, @var{p}, @var{k}, @var{tsam}, @dots{}) -## Create transfer function model from zero-pole-gain data. -## -## @strong{Inputs} -## @table @var -## @item sys -## LTI model to be converted to transfer function. -## @item num -## Numerator or cell of numerators. Each numerator must be a row vector -## containing the coefficients of the polynomial in descending powers of -## the transfer function variable. -## @item den -## Denominator or cell of denominators. Each denominator must be a row vector -## containing the coefficients of the polynomial in descending powers of -## the transfer function variable. -## @item tsam -## Sampling time in seconds. If @var{tsam} is not specified, a continuous-time -## model is assumed. -## @item @dots{} -## Optional pairs of properties and values. -## Type @command{set (tf)} for more information. -## @end table -## -## @strong{Outputs} -## @table @var -## @item sys -## Transfer function model. -## @end table -## -## @strong{Example} -## @example -## @group -## @end group -## @end example -## -## @seealso{tf, ss, dss, frd} -## @end deftypefn - -## Author: Lukas Reichlin <lukas.reichlin@gmail.com> -## Created: September 2011 -## Version: 0.1 - -function sys = zpk (z = {}, p = {}, k = [], varargin) - - switch (nargin) - case 0 - sys = tf (); - return; - - case 1 - if (isa (z, "lti") || is_real_matrix (z) || ischar (z)) - sys = tf (z); - return; - else - print_usage (); - endif - - case 2 - if (ischar (z) && issample (p, -1)) - sys = tf (z, p); - else - print_usage (); - endif - - otherwise - if (! iscell (z)) - z = {z}; - endif - if (! iscell (p)) - p = {p}; - endif - num = cellfun (@(zer, gain) real (gain * poly (zer)), z, num2cell (k), "uniformoutput", false); - den = cellfun (@(pol) real (poly (pol)), p, "uniformoutput", false); - sys = tf (num, den, varargin{:}); - endswitch - -endfunction -
--- a/main/control/doc/NEWS Wed Sep 21 19:44:48 2011 +0000 +++ b/main/control/doc/NEWS Wed Sep 21 20:22:37 2011 +0000 @@ -14,6 +14,11 @@ realization of SLICOT TD04AD is a minimal one. Therefore certain poles and zeros might be missing. +** zpk, @lti/zpkdata + -- Included wrappers that create transfer function model from zero-pole-gain + data (zpk) and zero-pole-gain data from lti models (zpkdata). They are + stop-gap measures for compatibility until ZPK models are implemented. + =============================================================================== control-2.1.55 Release Date: 2011-09-07 Release Manager: Lukas Reichlin
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main/control/inst/zpk.m Wed Sep 21 20:22:37 2011 +0000 @@ -0,0 +1,104 @@ +## Copyright (C) 2011 Lukas F. Reichlin +## +## This file is part of LTI Syncope. +## +## LTI Syncope is free software: you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation, either version 3 of the License, or +## (at your option) any later version. +## +## LTI Syncope is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {Function File} {@var{s} =} zpk (@var{"s"}) +## @deftypefnx {Function File} {@var{z} =} zpk (@var{"z"}, @var{tsam}) +## @deftypefnx {Function File} {@var{sys} =} zpk (@var{sys}) +## @deftypefnx {Function File} {@var{sys} =} zpk (@var{k}) +## @deftypefnx {Function File} {@var{sys} =} zpk (@var{z}, @var{p}, @var{k}, @dots{}) +## @deftypefnx {Function File} {@var{sys} =} zpk @var{z}, @var{p}, @var{k}, @var{tsam}, @dots{}) +## @deftypefnx {Function File} {@var{sys} =} zpk (@var{z}, @var{p}, @var{k}, @var{tsam}, @dots{}) +## Create transfer function model from zero-pole-gain data. +## This is just a stop-gap compatibility wrapper since zpk +## models are not yet implemented. +## +## @strong{Inputs} +## @table @var +## @item sys +## LTI model to be converted to transfer function. +## @item z +## Cell of vectors containing the zeros for each channel. +## z@{i,j@} contains the zeros from input j to output i. +## In the SISO case, a single vector is accepted as well. +## @item p +## Cell of vectors containing the poles for each channel. +## p@{i,j@} contains the poles from input j to output i. +## In the SISO case, a single vector is accepted as well. +## @item k +## Matrix containing the gains for each channel. +## k(i,j) contains the gain from input j to output i. +## @item tsam +## Sampling time in seconds. If @var{tsam} is not specified, +## a continuous-time model is assumed. +## @item @dots{} +## Optional pairs of properties and values. +## Type @command{set (tf)} for more information. +## @end table +## +## @strong{Outputs} +## @table @var +## @item sys +## Transfer function model. +## @end table +## +## @seealso{tf, ss, dss, frd} +## @end deftypefn + +## Author: Lukas Reichlin <lukas.reichlin@gmail.com> +## Created: September 2011 +## Version: 0.1 + +function sys = zpk (z = {}, p = {}, k = [], varargin) + + switch (nargin) + case 0 + sys = tf (); + return; + + case 1 + if (isa (z, "lti") || is_real_matrix (z) || ischar (z)) + sys = tf (z); + return; + else + print_usage (); + endif + + case 2 + if (ischar (z) && issample (p, -1)) + sys = tf (z, p); + else + print_usage (); + endif + + otherwise + if (! iscell (z)) + z = {z}; + endif + if (! iscell (p)) + p = {p}; + endif + if (! size_equal (z, p, k)) + error ("zpk: arguments z, p and k must have equal dimensions"); + endif + num = cellfun (@(zer, gain) real (gain * poly (zer)), z, num2cell (k), "uniformoutput", false); + den = cellfun (@(pol) real (poly (pol)), p, "uniformoutput", false); + sys = tf (num, den, varargin{:}); + endswitch + +endfunction +