Mercurial > forge
changeset 9314:00980855eafa octave-forge
signal: add x2y conversions
author | paramaniac |
---|---|
date | Fri, 06 Jan 2012 14:28:55 +0000 |
parents | 98859fc3b614 |
children | 82e4ab4b049c |
files | main/signal/inst/ss2tf.m main/signal/inst/ss2zp.m main/signal/inst/tf2ss.m main/signal/inst/tf2zp.m main/signal/inst/zp2ss.m main/signal/inst/zp2tf.m |
diffstat | 6 files changed, 324 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main/signal/inst/ss2tf.m Fri Jan 06 14:28:55 2012 +0000 @@ -0,0 +1,66 @@ +## Copyright (C) 1996, 2000, 2004, 2005, 2007 +## Auburn University. All rights reserved. +## Copyright (C) 2012 Lukas F. Reichlin +## +## This program 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. +## +## This program 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 this program; see the file COPYING. If not, see +## <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{num}, @var{den}] =} ss2tf (@var{a}, @var{b}, @var{c}, @var{d}) +## Conversion from transfer function to state-space. +## The state space system: +## @iftex +## @tex +## $$ \dot x = Ax + Bu $$ +## $$ y = Cx + Du $$ +## @end tex +## @end iftex +## @ifinfo +## @example +## . +## x = Ax + Bu +## y = Cx + Du +## @end example +## @end ifinfo +## +## is converted to a transfer function: +## @iftex +## @tex +## $$ G(s) = { { \rm num }(s) \over { \rm den }(s) } $$ +## @end tex +## @end iftex +## @ifinfo +## @example +## +## num(s) +## G(s)=------- +## den(s) +## @end example +## @end ifinfo +## +## @end deftypefn + +## Author: R. Bruce Tenison <btenison@eng.auburn.edu> +## Created: June 24, 1994 +## a s hodel: modified to allow for pure gain blocks Aug 1996 + +function [num, den] = ss2tf (varargin) + + if (nargin == 0) + print_usage (); + endif + + [num, den] = tfdata (ss (varargin{:}), "vector"); + +endfunction
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main/signal/inst/ss2zp.m Fri Jan 06 14:28:55 2012 +0000 @@ -0,0 +1,39 @@ +## Copyright (C) 1996, 2000, 2004, 2005, 2006, 2007 +## Auburn University. All rights reserved. +## Copyright (C) 2012 Lukas F. Reichlin +## +## This program 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. +## +## This program 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 this program; see the file COPYING. If not, see +## <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{pol}, @var{zer}, @var{k}] =} ss2zp (@var{a}, @var{b}, @var{c}, @var{d}) +## Converts a state space representation to a set of poles and zeros; +## @var{k} is a gain associated with the zeros. +## +## @end deftypefn + +## Author: David Clem +## Created: August 15, 1994 +## Hodel: changed order of output arguments to zer, pol, k. July 1996 +## a s hodel: added argument checking, allow for pure gain blocks aug 1996 + +function [z, p, k] = ss2zp (varargin) + + if (nargin == 0) + print_usage (); + endif + + [z, p, k] = zpkdata (ss (varargin{:}), "vector"); + +endfunction
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main/signal/inst/tf2ss.m Fri Jan 06 14:28:55 2012 +0000 @@ -0,0 +1,67 @@ +## Copyright (C) 1996, 1998, 2000, 2002, 2004, 2005, 2007 +## Auburn University. All rights reserved. +## Copyright (C) 2012 Lukas F. Reichlin +## +## This program 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. +## +## This program 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 this program; see the file COPYING. If not, see +## <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{a}, @var{b}, @var{c}, @var{d}] =} tf2ss (@var{num}, @var{den}) +## Conversion from transfer function to state-space. +## The state space system: +## @iftex +## @tex +## $$ \dot x = Ax + Bu $$ +## $$ y = Cx + Du $$ +## @end tex +## @end iftex +## @ifinfo +## @example +## . +## x = Ax + Bu +## y = Cx + Du +## @end example +## @end ifinfo +## is obtained from a transfer function: +## @iftex +## @tex +## $$ G(s) = { { \rm num }(s) \over { \rm den }(s) } $$ +## @end tex +## @end iftex +## @ifinfo +## @example +## num(s) +## G(s)=------- +## den(s) +## @end example +## @end ifinfo +## +## The state space system matrices obtained from this function +## will be in observable companion form as Wolovich's Observable +## Structure Theorem is used. +## @end deftypefn + +## Author: R. Bruce Tenison <btenison@eng.auburn.edu> +## Created: June 22, 1994 +## mod A S Hodel July, Aug 1995 + +function [a, b, c, d, e] = tf2ss (varargin) + + if (nargin == 0) + print_usage (); + endif + + [a, b, c, d, e] = dssdata (tf (varargin{:}), []); + +endfunction
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main/signal/inst/tf2zp.m Fri Jan 06 14:28:55 2012 +0000 @@ -0,0 +1,38 @@ +## Copyright (C) 1996, 1998, 2000, 2003, 2004, 2005, 2006, 2007 +## Auburn University. All rights reserved. +## Copyright (C) 2012 Lukas F. Reichlin +## +## This program 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. +## +## This program 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 this program; see the file COPYING. If not, see +## <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{zer}, @var{pol}, @var{k}] =} tf2zp (@var{num}, @var{den}) +## Converts transfer functions to poles-and-zero representations. +## +## Returns the zeros and poles of the system defined +## by @var{num}/@var{den}. +## @var{k} is a gain associated with the system zeros. +## @end deftypefn + +## Author: A. S. Hodel <a.s.hodel@eng.auburn.edu> + +function [z, p, k] = tf2zp (varargin) + + if (nargin == 0) + print_usage (); + endif + + [z, p, k] = zpkdata (tf (varargin{:}), "vector"); + +endfunction
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main/signal/inst/zp2ss.m Fri Jan 06 14:28:55 2012 +0000 @@ -0,0 +1,69 @@ +## Copyright (C) 1996, 2000, 2002, 2003, 2004, 2005, 2007 +## Auburn University. All rights reserved. +## Copyright (C) 2012 Lukas F. Reichlin +## +## This program 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. +## +## This program 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 this program; see the file COPYING. If not, see +## <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{a}, @var{b}, @var{c}, @var{d}] =} zp2ss (@var{zer}, @var{pol}, @var{k}) +## Conversion from zero / pole to state space. +## +## @strong{Inputs} +## @table @var +## @item zer +## @itemx pol +## Vectors of (possibly) complex poles and zeros of a transfer +## function. Complex values must come in conjugate pairs +## (i.e., @math{x+jy} in @var{zer} means that @math{x-jy} is also in @var{zer}). +## @item k +## Real scalar (leading coefficient). +## @end table +## +## @strong{Outputs} +## @table @var +## @item @var{a} +## @itemx @var{b} +## @itemx @var{c} +## @itemx @var{d} +## The state space system, in the form: +## @iftex +## @tex +## $$ \dot x = Ax + Bu $$ +## $$ y = Cx + Du $$ +## @end tex +## @end iftex +## @ifinfo +## @example +## . +## x = Ax + Bu +## y = Cx + Du +## @end example +## @end ifinfo +## @end table +## @end deftypefn + +## Author: David Clem +## Created: August 15, 1994 + +function [a, b, c, d, e] = zp2ss (varargin) + + if (nargin == 0) + print_usage (); + endif + + [a, b, c, d, e] = dssdata (zpk (varargin{:}), []); + +endfunction +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main/signal/inst/zp2tf.m Fri Jan 06 14:28:55 2012 +0000 @@ -0,0 +1,45 @@ +## Copyright (C) 1996, 1998, 2000, 2002, 2004, 2005, 2007 +## Auburn University. All rights reserved. +## Copyright (C) 2012 Lukas F. Reichlin +## +## This program 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. +## +## This program 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 this program; see the file COPYING. If not, see +## <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{num}, @var{den}] =} zp2tf (@var{zer}, @var{pol}, @var{k}) +## Converts zeros / poles to a transfer function. +## +## @strong{Inputs} +## @table @var +## @item zer +## @itemx pol +## Vectors of (possibly complex) poles and zeros of a transfer +## function. Complex values must appear in conjugate pairs. +## @item k +## Real scalar (leading coefficient). +## @end table +## @end deftypefn + +## Author: A. S. Hodel <a.s.hodel@eng.auburn.edu> +## (With help from students Ingram, McGowan.) + +function [num, den] = zp2tf (varargin) + + if (nargin == 0) + print_usage (); + endif + + [num, den] = tfdata (zpk (varargin{:}), "vector"); + +endfunction