From: <par...@us...> - 2010-09-15 00:36:54
|
Revision: 7723 http://octave.svn.sourceforge.net/octave/?rev=7723&view=rev Author: paramaniac Date: 2010-09-15 00:36:45 +0000 (Wed, 15 Sep 2010) Log Message: ----------- control: try sticking to GNU coding standards (still more to come) Modified Paths: -------------- trunk/octave-forge/main/control/inst/@lti/append.m trunk/octave-forge/main/control/inst/@lti/connect.m trunk/octave-forge/main/control/inst/@lti/feedback.m trunk/octave-forge/main/control/inst/@lti/horzcat.m trunk/octave-forge/main/control/inst/@lti/inv.m trunk/octave-forge/main/control/inst/@lti/lft.m trunk/octave-forge/main/control/inst/@lti/mconnect.m trunk/octave-forge/main/control/inst/@lti/minus.m trunk/octave-forge/main/control/inst/@lti/mldivide.m trunk/octave-forge/main/control/inst/@lti/mrdivide.m trunk/octave-forge/main/control/inst/@lti/mtimes.m trunk/octave-forge/main/control/inst/@lti/plus.m trunk/octave-forge/main/control/inst/@lti/sminreal.m trunk/octave-forge/main/control/inst/@lti/ssdata.m trunk/octave-forge/main/control/inst/@lti/subsref.m trunk/octave-forge/main/control/inst/@lti/tfdata.m trunk/octave-forge/main/control/inst/@lti/vertcat.m trunk/octave-forge/main/control/inst/@lti/xperm.m trunk/octave-forge/main/control/inst/@tf/__minreal__.m Added Paths: ----------- trunk/octave-forge/main/control/inst/@ss/__sys_connect__.m trunk/octave-forge/main/control/inst/@ss/__sys_data__.m trunk/octave-forge/main/control/inst/@ss/__sys_group__.m trunk/octave-forge/main/control/inst/@ss/__sys_inverse__.m trunk/octave-forge/main/control/inst/@ss/__sys_prune__.m trunk/octave-forge/main/control/inst/@tf/__sys_connect__.m trunk/octave-forge/main/control/inst/@tf/__sys_data__.m trunk/octave-forge/main/control/inst/@tf/__sys_group__.m trunk/octave-forge/main/control/inst/@tf/__sys_inverse__.m trunk/octave-forge/main/control/inst/@tf/__sys_prune__.m Removed Paths: ------------- trunk/octave-forge/main/control/inst/@ss/__getsysdata__.m trunk/octave-forge/main/control/inst/@ss/__sysconnect__.m trunk/octave-forge/main/control/inst/@ss/__sysgroup__.m trunk/octave-forge/main/control/inst/@ss/__sysinv__.m trunk/octave-forge/main/control/inst/@ss/__sysprune__.m trunk/octave-forge/main/control/inst/@tf/__getsysdata__.m trunk/octave-forge/main/control/inst/@tf/__sysconnect__.m trunk/octave-forge/main/control/inst/@tf/__sysgroup__.m trunk/octave-forge/main/control/inst/@tf/__sysinv__.m trunk/octave-forge/main/control/inst/@tf/__sysprune__.m Modified: trunk/octave-forge/main/control/inst/@lti/append.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/append.m 2010-09-15 00:13:40 UTC (rev 7722) +++ trunk/octave-forge/main/control/inst/@lti/append.m 2010-09-15 00:36:45 UTC (rev 7723) @@ -30,7 +30,7 @@ if (nargin > 1) for k = 2 : nargin - sys = __sysgroup__ (sys, varargin{k}); + sys = __sys_group__ (sys, varargin{k}); endfor endif Modified: trunk/octave-forge/main/control/inst/@lti/connect.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/connect.m 2010-09-15 00:13:40 UTC (rev 7722) +++ trunk/octave-forge/main/control/inst/@lti/connect.m 2010-09-15 00:36:45 UTC (rev 7723) @@ -53,7 +53,7 @@ endfor endfor - sys = __sysconnect__ (sys, M); - sys = __sysprune__ (sys, out_idx, in_idx); + sys = __sys_connect__ (sys, M); + sys = __sys_prune__ (sys, out_idx, in_idx); endfunction \ No newline at end of file Modified: trunk/octave-forge/main/control/inst/@lti/feedback.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/feedback.m 2010-09-15 00:13:40 UTC (rev 7722) +++ trunk/octave-forge/main/control/inst/@lti/feedback.m 2010-09-15 00:36:45 UTC (rev 7723) @@ -133,9 +133,9 @@ in_idx = 1 : m1; out_idx = 1 : p1; - sys = __sysgroup__ (sys1, sys2); - sys = __sysconnect__ (sys, M); - sys = __sysprune__ (sys, out_idx, in_idx); + sys = __sys_group__ (sys1, sys2); + sys = __sys_connect__ (sys, M); + sys = __sys_prune__ (sys, out_idx, in_idx); endfunction Modified: trunk/octave-forge/main/control/inst/@lti/horzcat.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/horzcat.m 2010-09-15 00:13:40 UTC (rev 7722) +++ trunk/octave-forge/main/control/inst/@lti/horzcat.m 2010-09-15 00:36:45 UTC (rev 7723) @@ -17,7 +17,7 @@ ## -*- texinfo -*- ## Horizontal concatenation of LTI objects. If necessary, object conversion -## is done by sysgroup. Used by Octave for "[lti1, lti2]". +## is done by sys_group. Used by Octave for "[lti1, lti2]". ## Author: Lukas Reichlin <luk...@gm...> ## Created: September 2009 @@ -38,7 +38,7 @@ p1, m1, p2, m2); endif - sys = __sysgroup__ (sys1, sys2); + sys = __sys_group__ (sys1, sys2); out_scl = [eye(p1), eye(p2)]; Modified: trunk/octave-forge/main/control/inst/@lti/inv.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/inv.m 2010-09-15 00:13:40 UTC (rev 7722) +++ trunk/octave-forge/main/control/inst/@lti/inv.m 2010-09-15 00:36:45 UTC (rev 7723) @@ -30,7 +30,7 @@ error ("lti: inv: system must be square"); endif - retsys = __sysinv__ (sys); + retsys = __sys_inverse__ (sys); ## TODO: handle i/o names Modified: trunk/octave-forge/main/control/inst/@lti/lft.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/lft.m 2010-09-15 00:13:40 UTC (rev 7722) +++ trunk/octave-forge/main/control/inst/@lti/lft.m 2010-09-15 00:36:45 UTC (rev 7723) @@ -95,7 +95,7 @@ print_usage (); endif - ## object conversion done by sysgroup if necessary + ## object conversion done by sys_group if necessary [p1, m1] = size (sys1); [p2, m2] = size (sys2); @@ -134,9 +134,9 @@ in_idx = [1 : (m1-nu), m1 + (ny+1 : m2)]; out_idx = [1 : (p1-ny), p1 + (nu+1 : p2)]; - sys = __sysgroup__ (sys1, sys2); - sys = __sysconnect__ (sys, M); - sys = __sysprune__ (sys, out_idx, in_idx); + sys = __sys_group__ (sys1, sys2); + sys = __sys_connect__ (sys, M); + sys = __sys_prune__ (sys, out_idx, in_idx); [p, m] = size (sys); Modified: trunk/octave-forge/main/control/inst/@lti/mconnect.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/mconnect.m 2010-09-15 00:13:40 UTC (rev 7722) +++ trunk/octave-forge/main/control/inst/@lti/mconnect.m 2010-09-15 00:36:45 UTC (rev 7723) @@ -79,10 +79,10 @@ error ("mconnect: second argument must be a matrix with real coefficients"); endif - sys = __sysconnect__ (sys, M); + sys = __sys_connect__ (sys, M); if (nargin == 4) - sys = __sysprune__ (sys, out_idx, in_idx); + sys = __sys_prune__ (sys, out_idx, in_idx); endif endfunction \ No newline at end of file Modified: trunk/octave-forge/main/control/inst/@lti/minus.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/minus.m 2010-09-15 00:13:40 UTC (rev 7722) +++ trunk/octave-forge/main/control/inst/@lti/minus.m 2010-09-15 00:36:45 UTC (rev 7723) @@ -17,7 +17,7 @@ ## -*- texinfo -*- ## Binary subtraction of LTI objects. If necessary, object conversion -## is done by sysgroup. Used by Octave for "lti1 - lti2". +## is done by sys_group. Used by Octave for "lti1 - lti2". ## Author: Lukas Reichlin <luk...@gm...> ## Created: September 2009 @@ -33,7 +33,7 @@ p1, m1, p2, m2); endif - sys = __sysgroup__ (sys1, sys2); + sys = __sys_group__ (sys1, sys2); in_scl = [eye(m1); eye(m2)]; out_scl = [eye(p1), -eye(p2)]; Modified: trunk/octave-forge/main/control/inst/@lti/mldivide.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/mldivide.m 2010-09-15 00:13:40 UTC (rev 7722) +++ trunk/octave-forge/main/control/inst/@lti/mldivide.m 2010-09-15 00:36:45 UTC (rev 7723) @@ -17,7 +17,7 @@ ## -*- texinfo -*- ## Matrix left division of LTI objects. If necessary, object conversion -## is done by sysgroup in mtimes. Used by Octave for "lti1 \ lti2". +## is done by sys_group in mtimes. Used by Octave for "lti1 \ lti2". ## Author: Lukas Reichlin <luk...@gm...> ## Created: October 2009 Modified: trunk/octave-forge/main/control/inst/@lti/mrdivide.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/mrdivide.m 2010-09-15 00:13:40 UTC (rev 7722) +++ trunk/octave-forge/main/control/inst/@lti/mrdivide.m 2010-09-15 00:36:45 UTC (rev 7723) @@ -17,7 +17,7 @@ ## -*- texinfo -*- ## Matrix right division of LTI objects. If necessary, object conversion -## is done by sysgroup in mtimes. Used by Octave for "lti1 / lti2". +## is done by sys_group in mtimes. Used by Octave for "lti1 / lti2". ## Author: Lukas Reichlin <luk...@gm...> ## Created: October 2009 Modified: trunk/octave-forge/main/control/inst/@lti/mtimes.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/mtimes.m 2010-09-15 00:13:40 UTC (rev 7722) +++ trunk/octave-forge/main/control/inst/@lti/mtimes.m 2010-09-15 00:36:45 UTC (rev 7723) @@ -17,7 +17,7 @@ ## -*- texinfo -*- ## Matrix multiplication of LTI objects. If necessary, object conversion -## is done by sysgroup. Used by Octave for "lti1 * lti2". +## is done by sys_group. Used by Octave for "lti1 * lti2". ## Author: Lukas Reichlin <luk...@gm...> ## Created: September 2009 @@ -44,9 +44,9 @@ out_idx = 1 : p2; in_idx = m2 + (1 : m1); - sys = __sysgroup__ (sys2, sys1); - sys = __sysconnect__ (sys, M); - sys = __sysprune__ (sys, out_idx, in_idx); + sys = __sys_group__ (sys2, sys1); + sys = __sys_connect__ (sys, M); + sys = __sys_prune__ (sys, out_idx, in_idx); endfunction Modified: trunk/octave-forge/main/control/inst/@lti/plus.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/plus.m 2010-09-15 00:13:40 UTC (rev 7722) +++ trunk/octave-forge/main/control/inst/@lti/plus.m 2010-09-15 00:36:45 UTC (rev 7723) @@ -17,7 +17,7 @@ ## -*- texinfo -*- ## Binary addition of LTI objects. If necessary, object conversion -## is done by sysgroup. Used by Octave for "lti1 + lti2". +## is done by sys_group. Used by Octave for "lti1 + lti2". ## Operation is also known as "parallel connection". ## Author: Lukas Reichlin <luk...@gm...> @@ -34,7 +34,7 @@ p1, m1, p2, m2); endif - sys = __sysgroup__ (sys1, sys2); + sys = __sys_group__ (sys1, sys2); in_scl = [eye(m1); eye(m2)]; out_scl = [eye(p1), eye(p2)]; Modified: trunk/octave-forge/main/control/inst/@lti/sminreal.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/sminreal.m 2010-09-15 00:13:40 UTC (rev 7722) +++ trunk/octave-forge/main/control/inst/@lti/sminreal.m 2010-09-15 00:36:45 UTC (rev 7723) @@ -71,7 +71,7 @@ st_idx = intersect (co_idx, ob_idx); - sys = __sysprune__ (sys, ":", ":", st_idx); + sys = __sys_prune__ (sys, ":", ":", st_idx); endfunction Modified: trunk/octave-forge/main/control/inst/@lti/ssdata.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/ssdata.m 2010-09-15 00:13:40 UTC (rev 7722) +++ trunk/octave-forge/main/control/inst/@lti/ssdata.m 2010-09-15 00:36:45 UTC (rev 7723) @@ -30,7 +30,7 @@ sys = ss (sys); endif - sysdata = __getsysdata__ (sys); + sysdata = __sys_data__ (sys); a = sysdata.a; b = sysdata.b; Modified: trunk/octave-forge/main/control/inst/@lti/subsref.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/subsref.m 2010-09-15 00:13:40 UTC (rev 7722) +++ trunk/octave-forge/main/control/inst/@lti/subsref.m 2010-09-15 00:36:45 UTC (rev 7723) @@ -35,7 +35,7 @@ case "()" idx = s(k).subs; if (numel (idx) == 2) - a = __sysprune__ (a, idx{1}, idx{2}); + a = __sys_prune__ (a, idx{1}, idx{2}); elseif (numel (idx) == 1) a = __freqresp__ (a, idx{1}); else Modified: trunk/octave-forge/main/control/inst/@lti/tfdata.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/tfdata.m 2010-09-15 00:13:40 UTC (rev 7722) +++ trunk/octave-forge/main/control/inst/@lti/tfdata.m 2010-09-15 00:36:45 UTC (rev 7723) @@ -31,7 +31,7 @@ sys = tf (sys); endif - sysdata = __getsysdata__ (sys); + sysdata = __sys_data__ (sys); num = sysdata.num; den = sysdata.den; Modified: trunk/octave-forge/main/control/inst/@lti/vertcat.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/vertcat.m 2010-09-15 00:13:40 UTC (rev 7722) +++ trunk/octave-forge/main/control/inst/@lti/vertcat.m 2010-09-15 00:36:45 UTC (rev 7723) @@ -17,7 +17,7 @@ ## -*- texinfo -*- ## Vertical concatenation of LTI objects. If necessary, object conversion -## is done by sysgroup. Used by Octave for "[lti1; lti2]". +## is done by sys_group. Used by Octave for "[lti1; lti2]". ## Author: Lukas Reichlin <luk...@gm...> ## Created: September 2009 @@ -38,7 +38,7 @@ p1, m1, p2, m2); endif - sys = __sysgroup__ (sys1, sys2); + sys = __sys_group__ (sys1, sys2); in_scl = [eye(m1); eye(m2)]; Modified: trunk/octave-forge/main/control/inst/@lti/xperm.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/xperm.m 2010-09-15 00:13:40 UTC (rev 7722) +++ trunk/octave-forge/main/control/inst/@lti/xperm.m 2010-09-15 00:36:45 UTC (rev 7723) @@ -39,6 +39,6 @@ sys = ss (sys); endif - sys = __sysprune__ (sys, ":", ":", st_idx); + sys = __sys_prune__ (sys, ":", ":", st_idx); endfunction \ No newline at end of file Deleted: trunk/octave-forge/main/control/inst/@ss/__getsysdata__.m =================================================================== --- trunk/octave-forge/main/control/inst/@ss/__getsysdata__.m 2010-09-15 00:13:40 UTC (rev 7722) +++ trunk/octave-forge/main/control/inst/@ss/__getsysdata__.m 2010-09-15 00:36:45 UTC (rev 7723) @@ -1,33 +0,0 @@ -## Copyright (C) 2009 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 this program. If not, see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## Used by ssdata instead of get (). - -## Author: Lukas Reichlin <luk...@gm...> -## Created: September 2009 -## Version: 0.1 - -function data = __getsysdata__ (sys) - - data.a = sys.a; - data.b = sys.b; - data.c = sys.c; - data.d = sys.d; - data.stname = sys.stname; - -endfunction \ No newline at end of file Added: trunk/octave-forge/main/control/inst/@ss/__sys_connect__.m =================================================================== --- trunk/octave-forge/main/control/inst/@ss/__sys_connect__.m (rev 0) +++ trunk/octave-forge/main/control/inst/@ss/__sys_connect__.m 2010-09-15 00:36:45 UTC (rev 7723) @@ -0,0 +1,87 @@ +## Copyright (C) 2009 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 this program. If not, see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {Function File} {@var{retsys} =} __sys_connect__ (@var{sys}, @var{M}) +## This function is part of the Model Abstraction Layer. No argument checking. +## For internal use only. +## @example +## @group +## Problem: Solve the system equations of +## . +## x(t) = A x(t) + B e(t) +## +## y(t) = C x(t) + D e(t) +## +## e(t) = u(t) + M y(t) +## +## in order to build +## . +## x(t) = F x(t) + G u(t) +## +## y(t) = H x(t) + J u(t) +## +## Solution: Laplace Transformation +## s X(s) = A X(s) + B U(s) + B M Y(s) [1] +## +## Y(s) = C X(s) + D U(s) + D M Y(s) [2] +## +## solve [2] for Y(s) +## Y(s) = [I - D M]^(-1) C X(s) + [I - D M]^(-1) D U(s) +## +## substitute Z = [I - D M]^(-1) +## Y(s) = Z C X(s) + Z D U(s) [3] +## +## insert [3] in [1], solve for X(s) +## X(s) = [s I - (A + B M Z C)]^(-1) (B + B M Z D) U(s) [4] +## +## inserting [4] in [3] finally yields +## Y(s) = Z C [s I - (A + B M Z C)]^(-1) (B + B M Z D) U(s) + Z D U(s) +## \ / \_____ _____/ \_____ _____/ \ / +## H F G J +## @end group +## @end example +## @end deftypefn + +## Author: Lukas Reichlin <luk...@gm...> +## Created: September 2009 +## Version: 0.1 + +function sys = __sys_connect__ (sys, M) + + [p, m] = size (sys); + + A = sys.a; + B = sys.b; + C = sys.c; + D = sys.d; + + I = eye (p); + Z = I - D*M; + + if (rcond (Z) < eps) # check for singularity + error ("ss: sys_connect: (I - D*M) not invertible"); + endif + + Z = inv (Z); + + sys.a = A + B*M*Z*C; # F + sys.b = B + B*M*Z*D; # G + sys.c = Z*C; # H + sys.d = Z*D; # J + +endfunction \ No newline at end of file Added: trunk/octave-forge/main/control/inst/@ss/__sys_data__.m =================================================================== --- trunk/octave-forge/main/control/inst/@ss/__sys_data__.m (rev 0) +++ trunk/octave-forge/main/control/inst/@ss/__sys_data__.m 2010-09-15 00:36:45 UTC (rev 7723) @@ -0,0 +1,33 @@ +## Copyright (C) 2009 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 this program. If not, see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## Used by ssdata instead of multiple get calls. + +## Author: Lukas Reichlin <luk...@gm...> +## Created: September 2009 +## Version: 0.1 + +function data = __sys_data__ (sys) + + data.a = sys.a; + data.b = sys.b; + data.c = sys.c; + data.d = sys.d; + data.stname = sys.stname; + +endfunction \ No newline at end of file Added: trunk/octave-forge/main/control/inst/@ss/__sys_group__.m =================================================================== --- trunk/octave-forge/main/control/inst/@ss/__sys_group__.m (rev 0) +++ trunk/octave-forge/main/control/inst/@ss/__sys_group__.m 2010-09-15 00:36:45 UTC (rev 7723) @@ -0,0 +1,76 @@ +## Copyright (C) 2009 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 this program. If not, see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## Block diagonal concatenation of two SS models. +## This file is part of the Model Abstraction Layer. +## For internal use only. + +## Author: Lukas Reichlin <luk...@gm...> +## Created: September 2009 +## Version: 0.1 + +function retsys = __sys_group__ (sys1, sys2) + + if (! isa (sys1, "ss")) + sys1 = ss (sys1); + endif + + if (! isa (sys2, "ss")) + sys2 = ss (sys2); + endif + + retsys = ss (); + + retsys.lti = __lti_group__ (sys1.lti, sys2.lti); + + A1 = sys1.a; + B1 = sys1.b; + C1 = sys1.c; + D1 = sys1.d; + A2 = sys2.a; + B2 = sys2.b; + C2 = sys2.c; + D2 = sys2.d; + + [m1, n1, p1] = __ss_dim__ (A1, B1, C1, D1); + [m2, n2, p2] = __ss_dim__ (A2, B2, C2, D2); + + A12 = zeros (n1, n2); + B12 = zeros (n1, m2); + B21 = zeros (n2, m1); + C12 = zeros (p1, n2); + C21 = zeros (p2, n1); + D12 = zeros (p1, m2); + D21 = zeros (p2, m1); + + retsys.a = [A1 , A12; + A12.', A2 ]; + + retsys.b = [B1 , B12; + B21, B2 ]; + + retsys.c = [C1 , C12; + C21, C2 ]; + + retsys.d = [D1 , D12; + D21, D2 ]; + + retsys.stname = [sys1.stname; + sys2.stname]; + +endfunction \ No newline at end of file Added: trunk/octave-forge/main/control/inst/@ss/__sys_inverse__.m =================================================================== --- trunk/octave-forge/main/control/inst/@ss/__sys_inverse__.m (rev 0) +++ trunk/octave-forge/main/control/inst/@ss/__sys_inverse__.m 2010-09-15 00:36:45 UTC (rev 7723) @@ -0,0 +1,48 @@ +## Copyright (C) 2009 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 this program. If not, see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## Inversion of SS models. + +## Author: Lukas Reichlin <luk...@gm...> +## Created: October 2009 +## Version: 0.1 + +function sys = __sys_inverse__ (sys) + + a = sys.a; + b = sys.b; + c = sys.c; + d = sys.d; + + if (rcond (d) < eps) + error ("ss: sys_inverse: inverse is not proper, case not implemented yet"); + else + di = inv (d); + + f = a - b * di * c; + g = b * di; + h = -di * c; + j = di; + endif + + sys.a = f; + sys.b = g; + sys.c = h; + sys.d = j; + +endfunction \ No newline at end of file Added: trunk/octave-forge/main/control/inst/@ss/__sys_prune__.m =================================================================== --- trunk/octave-forge/main/control/inst/@ss/__sys_prune__.m (rev 0) +++ trunk/octave-forge/main/control/inst/@ss/__sys_prune__.m 2010-09-15 00:36:45 UTC (rev 7723) @@ -0,0 +1,38 @@ +## Copyright (C) 2009 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 this program. If not, see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## Submodel extraction and reordering for SS objects. +## This file is part of the Model Abstraction Layer. +## For internal use only. + +## Author: Lukas Reichlin <luk...@gm...> +## Created: September 2009 +## Version: 0.1 + +function sys = __sys_prune__ (sys, out_idx, in_idx, st_idx = ":") + + sys.lti = __lti_prune__ (sys.lti, out_idx, in_idx); + + sys.a = sys.a(st_idx, st_idx); + sys.b = sys.b(st_idx, in_idx); + sys.c = sys.c(out_idx, st_idx); + sys.d = sys.d(out_idx, in_idx); + + sys.stname = sys.stname(st_idx); + +endfunction \ No newline at end of file Deleted: trunk/octave-forge/main/control/inst/@ss/__sysconnect__.m =================================================================== --- trunk/octave-forge/main/control/inst/@ss/__sysconnect__.m 2010-09-15 00:13:40 UTC (rev 7722) +++ trunk/octave-forge/main/control/inst/@ss/__sysconnect__.m 2010-09-15 00:36:45 UTC (rev 7723) @@ -1,87 +0,0 @@ -## Copyright (C) 2009 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 this program. If not, see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {Function File} {@var{retsys} =} __sysconnect__ (@var{sys}, @var{M}) -## This function is part of the Model Abstraction Layer. No argument checking. -## For internal use only. -## @example -## @group -## Problem: Solve the system equations of -## . -## x(t) = A x(t) + B e(t) -## -## y(t) = C x(t) + D e(t) -## -## e(t) = u(t) + M y(t) -## -## in order to build -## . -## x(t) = F x(t) + G u(t) -## -## y(t) = H x(t) + J u(t) -## -## Solution: Laplace Transformation -## s X(s) = A X(s) + B U(s) + B M Y(s) [1] -## -## Y(s) = C X(s) + D U(s) + D M Y(s) [2] -## -## solve [2] for Y(s) -## Y(s) = [I - D M]^(-1) C X(s) + [I - D M]^(-1) D U(s) -## -## substitute Z = [I - D M]^(-1) -## Y(s) = Z C X(s) + Z D U(s) [3] -## -## insert [3] in [1], solve for X(s) -## X(s) = [s I - (A + B M Z C)]^(-1) (B + B M Z D) U(s) [4] -## -## inserting [4] in [3] finally yields -## Y(s) = Z C [s I - (A + B M Z C)]^(-1) (B + B M Z D) U(s) + Z D U(s) -## \ / \_____ _____/ \_____ _____/ \ / -## H F G J -## @end group -## @end example -## @end deftypefn - -## Author: Lukas Reichlin <luk...@gm...> -## Created: September 2009 -## Version: 0.1 - -function sys = __sysconnect__ (sys, M) - - [p, m] = size (sys); - - A = sys.a; - B = sys.b; - C = sys.c; - D = sys.d; - - I = eye (p); - Z = I - D*M; - - if (rcond (Z) < eps) # check for singularity - error ("ss: sysconnect: (I - D*M) not invertible"); - endif - - Z = inv (Z); - - sys.a = A + B*M*Z*C; # F - sys.b = B + B*M*Z*D; # G - sys.c = Z*C; # H - sys.d = Z*D; # J - -endfunction \ No newline at end of file Deleted: trunk/octave-forge/main/control/inst/@ss/__sysgroup__.m =================================================================== --- trunk/octave-forge/main/control/inst/@ss/__sysgroup__.m 2010-09-15 00:13:40 UTC (rev 7722) +++ trunk/octave-forge/main/control/inst/@ss/__sysgroup__.m 2010-09-15 00:36:45 UTC (rev 7723) @@ -1,76 +0,0 @@ -## Copyright (C) 2009 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 this program. If not, see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## Block diagonal concatenation of two SS models. -## This file is part of the Model Abstraction Layer. -## For internal use only. - -## Author: Lukas Reichlin <luk...@gm...> -## Created: September 2009 -## Version: 0.1 - -function retsys = __sysgroup__ (sys1, sys2) - - if (! isa (sys1, "ss")) - sys1 = ss (sys1); - endif - - if (! isa (sys2, "ss")) - sys2 = ss (sys2); - endif - - retsys = ss (); - - retsys.lti = __lti_group__ (sys1.lti, sys2.lti); - - A1 = sys1.a; - B1 = sys1.b; - C1 = sys1.c; - D1 = sys1.d; - A2 = sys2.a; - B2 = sys2.b; - C2 = sys2.c; - D2 = sys2.d; - - [m1, n1, p1] = __ss_dim__ (A1, B1, C1, D1); - [m2, n2, p2] = __ss_dim__ (A2, B2, C2, D2); - - A12 = zeros (n1, n2); - B12 = zeros (n1, m2); - B21 = zeros (n2, m1); - C12 = zeros (p1, n2); - C21 = zeros (p2, n1); - D12 = zeros (p1, m2); - D21 = zeros (p2, m1); - - retsys.a = [A1 , A12; - A12.', A2 ]; - - retsys.b = [B1 , B12; - B21, B2 ]; - - retsys.c = [C1 , C12; - C21, C2 ]; - - retsys.d = [D1 , D12; - D21, D2 ]; - - retsys.stname = [sys1.stname; - sys2.stname]; - -endfunction \ No newline at end of file Deleted: trunk/octave-forge/main/control/inst/@ss/__sysinv__.m =================================================================== --- trunk/octave-forge/main/control/inst/@ss/__sysinv__.m 2010-09-15 00:13:40 UTC (rev 7722) +++ trunk/octave-forge/main/control/inst/@ss/__sysinv__.m 2010-09-15 00:36:45 UTC (rev 7723) @@ -1,48 +0,0 @@ -## Copyright (C) 2009 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 this program. If not, see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## Inversion of SS models. - -## Author: Lukas Reichlin <luk...@gm...> -## Created: October 2009 -## Version: 0.1 - -function sys = __sysinv__ (sys) - - a = sys.a; - b = sys.b; - c = sys.c; - d = sys.d; - - if (rcond (d) < eps) - error ("ss: sysinv: inverse is not proper, case not implemented yet"); - else - di = inv (d); - - f = a - b * di * c; - g = b * di; - h = -di * c; - j = di; - endif - - sys.a = f; - sys.b = g; - sys.c = h; - sys.d = j; - -endfunction \ No newline at end of file Deleted: trunk/octave-forge/main/control/inst/@ss/__sysprune__.m =================================================================== --- trunk/octave-forge/main/control/inst/@ss/__sysprune__.m 2010-09-15 00:13:40 UTC (rev 7722) +++ trunk/octave-forge/main/control/inst/@ss/__sysprune__.m 2010-09-15 00:36:45 UTC (rev 7723) @@ -1,38 +0,0 @@ -## Copyright (C) 2009 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 this program. If not, see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## Submodel extraction and reordering for SS objects. -## This file is part of the Model Abstraction Layer. -## For internal use only. - -## Author: Lukas Reichlin <luk...@gm...> -## Created: September 2009 -## Version: 0.1 - -function sys = __sysprune__ (sys, out_idx, in_idx, st_idx = ":") - - sys.lti = __lti_prune__ (sys.lti, out_idx, in_idx); - - sys.a = sys.a(st_idx, st_idx); - sys.b = sys.b(st_idx, in_idx); - sys.c = sys.c(out_idx, st_idx); - sys.d = sys.d(out_idx, in_idx); - - sys.stname = sys.stname(st_idx); - -endfunction \ No newline at end of file Deleted: trunk/octave-forge/main/control/inst/@tf/__getsysdata__.m =================================================================== --- trunk/octave-forge/main/control/inst/@tf/__getsysdata__.m 2010-09-15 00:13:40 UTC (rev 7722) +++ trunk/octave-forge/main/control/inst/@tf/__getsysdata__.m 2010-09-15 00:36:45 UTC (rev 7723) @@ -1,31 +0,0 @@ -## Copyright (C) 2009 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 this program. If not, see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## Used by tfdata instead of get (). - -## Author: Lukas Reichlin <luk...@gm...> -## Created: October 2009 -## Version: 0.1 - -function data = __getsysdata__ (sys) - - data.num = sys.num; - data.den = sys.den; - data.tfvar = sys.tfvar; - -endfunction \ No newline at end of file Modified: trunk/octave-forge/main/control/inst/@tf/__minreal__.m =================================================================== --- trunk/octave-forge/main/control/inst/@tf/__minreal__.m 2010-09-15 00:13:40 UTC (rev 7722) +++ trunk/octave-forge/main/control/inst/@tf/__minreal__.m 2010-09-15 00:36:45 UTC (rev 7723) @@ -33,7 +33,7 @@ for ny = 1 : p for nu = 1 : m - sisosys = __sysprune__ (sys, ny, nu); + sisosys = __sys_prune__ (sys, ny, nu); [zer, gain] = zero (sisosys); pol = pole (sisosys); Added: trunk/octave-forge/main/control/inst/@tf/__sys_connect__.m =================================================================== --- trunk/octave-forge/main/control/inst/@tf/__sys_connect__.m (rev 0) +++ trunk/octave-forge/main/control/inst/@tf/__sys_connect__.m 2010-09-15 00:36:45 UTC (rev 7723) @@ -0,0 +1,99 @@ +## Copyright (C) 2009 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 this program. If not, see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {Function File} {@var{retsys} =} __sys_connect__ (@var{sys}, @var{M}) +## This function is part of the Model Abstraction Layer. No argument checking. +## For internal use only. +## @example +## @group +## Problem: Solve the system equations of +## Y(s) = G(s) E(s) +## E(s) = U(s) + M Y(s) +## in order to build +## Y(s) = H(s) U(s) +## Solution: +## Y(s) = G(s) [I - M G(s)]^-1 U(s) +## = [I - G(s) M]^-1 G(s) U(s) +## @end group +## @end example +## @end deftypefn + +## Author: Lukas Reichlin <luk...@gm...> +## Created: October 2009 +## Version: 0.1 + +function sys = __sys_connect__ (sys, M) + + [p, m] = size (sys); + + num = sys.num; + den = sys.den; + + ## TODO: Implementation for MIMO models. There are three possibilities: + ## 1. An _algebraic_ solution of the inversion problem in order + ## to not introduce unwanted zero/pole pairs. Difficult. + ## 2. A numeric solution of the inversion problem. Afterwards, + ## elimination of _all_ zero/pole pairs by minreal. Bad. + ## 3. Conversion to state-space, solving the problem there and + ## converting back to transfer function. Easier, but obviously, + ## this way needs MIMO __sys2ss__ and __sys2tf__ implementations + ## as described in Thomas Kailath's classic "Linear Systems". + ## Possibly this is the way to go, but it works for proper systems + ## only unless descriptor state-space models are implemented. + + ## WARNING: The code below is a cheap hack to quickly enable SISO TF connections. + + ## TODO: Check for den = 0, e.g. in feedback (tf (1), tf (-1)) + + if (m == 2 && p == 2 && num{1,2} == 0 && num{2,1} == 0) + sys.num(1,1) = num{1,1} * den{2,2}; + sys.num(1,2) = M(1,2) * num{1,1} * num{2,2}; + sys.num(2,1) = M(2,1) * num{1,1} * num{2,2}; + sys.num(2,2) = num{2,2} * den{1,1}; + + sys.den(:) = den{1,1} * den{2,2} - M(1,2) * M(2,1) * num{1,1} * num{2,2}; + + elseif (m == 4 && p == 3) # TODO: extend check + sys.num(:) = tfpoly (0); + sys.den(:) = tfpoly (1); + + sys.num(1,1) = num{1,1}; + sys.num(1,2) = num{1,2}; + sys.num(1,3) = num{1,1} * num{2,3}; + sys.num(1,4) = num{1,2} * num{3,4}; + sys.num(2,3) = num{2,3}; + sys.num(3,4) = num{3,4}; + + sys.den(1,3) = den{2,3}; + sys.den(1,4) = den{3,4}; + sys.den(2,3) = den{2,3}; + sys.den(3,4) = den{3,4}; + + elseif (m == 3 && p == 3) # TODO: extend check + sys.num = num; + sys.den = den; + + sys.num(1,3) = num{1,1} * den{1,2} + num{1,2} * den{1,1}; + sys.den(1,3) = den{1,1} * den{1,2}; + + else + error ("tf: sys_connect: MIMO systems not supported yet"); + + endif + +endfunction \ No newline at end of file Added: trunk/octave-forge/main/control/inst/@tf/__sys_data__.m =================================================================== --- trunk/octave-forge/main/control/inst/@tf/__sys_data__.m (rev 0) +++ trunk/octave-forge/main/control/inst/@tf/__sys_data__.m 2010-09-15 00:36:45 UTC (rev 7723) @@ -0,0 +1,31 @@ +## Copyright (C) 2009 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 this program. If not, see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## Used by tfdata instead of multiple get calls. + +## Author: Lukas Reichlin <luk...@gm...> +## Created: October 2009 +## Version: 0.1 + +function data = __sys_data__ (sys) + + data.num = sys.num; + data.den = sys.den; + data.tfvar = sys.tfvar; + +endfunction \ No newline at end of file Added: trunk/octave-forge/main/control/inst/@tf/__sys_group__.m =================================================================== --- trunk/octave-forge/main/control/inst/@tf/__sys_group__.m (rev 0) +++ trunk/octave-forge/main/control/inst/@tf/__sys_group__.m 2010-09-15 00:36:45 UTC (rev 7723) @@ -0,0 +1,64 @@ +## Copyright (C) 2009 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 this program. If not, see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## Block diagonal concatenation of two TF models. +## This file is part of the Model Abstraction Layer. +## For internal use only. + +## Author: Lukas Reichlin <luk...@gm...> +## Created: September 2009 +## Version: 0.1 + +function retsys = __sys_group__ (sys1, sys2) + + if (! isa (sys1, "tf")) + sys1 = tf (sys1); + endif + + if (! isa (sys2, "tf")) + sys2 = tf (sys2); + endif + + retsys = tf (); + + retsys.lti = __lti_group__ (sys1.lti, sys2.lti); + + [p1, m1] = size (sys1); + [p2, m2] = size (sys2); + + empty12 = tfpolyzeros (p1, m2); + empty21 = tfpolyzeros (p2, m1); + + retsys.num = [sys1.num, empty12 ; + empty21, sys2.num]; + + empty12 = tfpolyones (p1, m2); + empty21 = tfpolyones (p2, m1); + + retsys.den = [sys1.den, empty12 ; + empty21, sys2.den]; + + if (sys1.tfvar == sys2.tfvar) + retsys.tfvar = sys1.tfvar; + elseif (sys1.tfvar == "x") + retsys.tfvar = sys2.tfvar; + else + retsys.tfvar = sys1.tfvar; + endif + +endfunction \ No newline at end of file Added: trunk/octave-forge/main/control/inst/@tf/__sys_inverse__.m =================================================================== --- trunk/octave-forge/main/control/inst/@tf/__sys_inverse__.m (rev 0) +++ trunk/octave-forge/main/control/inst/@tf/__sys_inverse__.m 2010-09-15 00:36:45 UTC (rev 7723) @@ -0,0 +1,46 @@ +## Copyright (C) 2009 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 this program. If not, see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## Inversion of TF models. + +## Author: Lukas Reichlin <luk...@gm...> +## Created: October 2009 +## Version: 0.1 + +function sys = __sys_inverse__ (sys) + + [p, m] = size (sys); + + ## TODO: inversion of MIMO TF models + + if (p != 1 || m != 1) + error ("tf: sys_inverse: MIMO systems not supported yet"); + endif + + den = sys.num; + num = sys.den; + + if (den{1, 1} == 0) # catch case den = 0 + num{1, 1} = tfpoly (0); + den{1, 1} = tfpoly (1); + endif + + sys.num = num; + sys.den = den; + +endfunction \ No newline at end of file Added: trunk/octave-forge/main/control/inst/@tf/__sys_prune__.m =================================================================== --- trunk/octave-forge/main/control/inst/@tf/__sys_prune__.m (rev 0) +++ trunk/octave-forge/main/control/inst/@tf/__sys_prune__.m 2010-09-15 00:36:45 UTC (rev 7723) @@ -0,0 +1,34 @@ +## Copyright (C) 2009 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 this program. If not, see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## Submodel extraction and reordering for TF objects. +## This file is part of the Model Abstraction Layer. +## For internal use only. + +## Author: Lukas Reichlin <luk...@gm...> +## Created: October 2009 +## Version: 0.1 + +function sys = __sys_prune__ (sys, out_idx, in_idx) + + sys.lti = __lti_prune__ (sys.lti, out_idx, in_idx); + + sys.num = sys.num(out_idx, in_idx); + sys.den = sys.den(out_idx, in_idx); + +endfunction \ No newline at end of file Deleted: trunk/octave-forge/main/control/inst/@tf/__sysconnect__.m =================================================================== --- trunk/octave-forge/main/control/inst/@tf/__sysconnect__.m 2010-09-15 00:13:40 UTC (rev 7722) +++ trunk/octave-forge/main/control/inst/@tf/__sysconnect__.m 2010-09-15 00:36:45 UTC (rev 7723) @@ -1,99 +0,0 @@ -## Copyright (C) 2009 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 this program. If not, see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {Function File} {@var{retsys} =} __sysconnect__ (@var{sys}, @var{M}) -## This function is part of the Model Abstraction Layer. No argument checking. -## For internal use only. -## @example -## @group -## Problem: Solve the system equations of -## Y(s) = G(s) E(s) -## E(s) = U(s) + M Y(s) -## in order to build -## Y(s) = H(s) U(s) -## Solution: -## Y(s) = G(s) [I - M G(s)]^-1 U(s) -## = [I - G(s) M]^-1 G(s) U(s) -## @end group -## @end example -## @end deftypefn - -## Author: Lukas Reichlin <luk...@gm...> -## Created: October 2009 -## Version: 0.1 - -function sys = __sysconnect__ (sys, M) - - [p, m] = size (sys); - - num = sys.num; - den = sys.den; - - ## TODO: Implementation for MIMO models. There are three possibilities: - ## 1. An _algebraic_ solution of the inversion problem in order - ## to not introduce unwanted zero/pole pairs. Difficult. - ## 2. A numeric solution of the inversion problem. Afterwards, - ## elimination of _all_ zero/pole pairs by minreal. Bad. - ## 3. Conversion to state-space, solving the problem there and - ## converting back to transfer function. Easier, but obviously, - ## this way needs MIMO __sys2ss__ and __sys2tf__ implementations - ## as described in Thomas Kailath's classic "Linear Systems". - ## Possibly this is the way to go, but it works for proper systems - ## only unless descriptor state-space models are implemented. - - ## WARNING: The code below is a cheap hack to quickly enable SISO TF connections. - - ## TODO: Check for den = 0, e.g. in feedback (tf (1), tf (-1)) - - if (m == 2 && p == 2 && num{1,2} == 0 && num{2,1} == 0) - sys.num(1,1) = num{1,1} * den{2,2}; - sys.num(1,2) = M(1,2) * num{1,1} * num{2,2}; - sys.num(2,1) = M(2,1) * num{1,1} * num{2,2}; - sys.num(2,2) = num{2,2} * den{1,1}; - - sys.den(:) = den{1,1} * den{2,2} - M(1,2) * M(2,1) * num{1,1} * num{2,2}; - - elseif (m == 4 && p == 3) # TODO: extend check - sys.num(:) = tfpoly (0); - sys.den(:) = tfpoly (1); - - sys.num(1,1) = num{1,1}; - sys.num(1,2) = num{1,2}; - sys.num(1,3) = num{1,1} * num{2,3}; - sys.num(1,4) = num{1,2} * num{3,4}; - sys.num(2,3) = num{2,3}; - sys.num(3,4) = num{3,4}; - - sys.den(1,3) = den{2,3}; - sys.den(1,4) = den{3,4}; - sys.den(2,3) = den{2,3}; - sys.den(3,4) = den{3,4}; - - elseif (m == 3 && p == 3) # TODO: extend check - sys.num = num; - sys.den = den; - - sys.num(1,3) = num{1,1} * den{1,2} + num{1,2} * den{1,1}; - sys.den(1,3) = den{1,1} * den{1,2}; - - else - error ("tf: sysconnect: MIMO systems not supported yet"); - - endif - -endfunction \ No newline at end of file Deleted: trunk/octave-forge/main/control/inst/@tf/__sysgroup__.m =================================================================== --- trunk/octave-forge/main/control/inst/@tf/__sysgroup__.m 2010-09-15 00:13:40 UTC (rev 7722) +++ trunk/octave-forge/main/control/inst/@tf/__sysgroup__.m 2010-09-15 00:36:45 UTC (rev 7723) @@ -1,64 +0,0 @@ -## Copyright (C) 2009 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 this program. If not, see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## Block diagonal concatenation of two TF models. -## This file is part of the Model Abstraction Layer. -## For internal use only. - -## Author: Lukas Reichlin <luk...@gm...> -## Created: September 2009 -## Version: 0.1 - -function retsys = __sysgroup__ (sys1, sys2) - - if (! isa (sys1, "tf")) - sys1 = tf (sys1); - endif - - if (! isa (sys2, "tf")) - sys2 = tf (sys2); - endif - - retsys = tf (); - - retsys.lti = __lti_group__ (sys1.lti, sys2.lti); - - [p1, m1] = size (sys1); - [p2, m2] = size (sys2); - - empty12 = tfpolyzeros (p1, m2); - empty21 = tfpolyzeros (p2, m1); - - retsys.num = [sys1.num, empty12 ; - empty21, sys2.num]; - - empty12 = tfpolyones (p1, m2); - empty21 = tfpolyones (p2, m1); - - retsys.den = [sys1.den, empty12 ; - empty21, sys2.den]; - - if (sys1.tfvar == sys2.tfvar) - retsys.tfvar = sys1.tfvar; - elseif (sys1.tfvar == "x") - retsys.tfvar = sys2.tfvar; - else - retsys.tfvar = sys1.tfvar; - endif - -endfunction \ No newline at end of file Deleted: trunk/octave-forge/main/control/inst/@tf/__sysinv__.m =================================================================== --- trunk/octave-forge/main/control/inst/@tf/__sysinv__.m 2010-09-15 00:13:40 UTC (rev 7722) +++ trunk/octave-forge/main/control/inst/@tf/__sysinv__.m 2010-09-15 00:36:45 UTC (rev 7723) @@ -1,46 +0,0 @@ -## Copyright (C) 2009 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 this program. If not, see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## Inversion of TF models. - -## Author: Lukas Reichlin <luk...@gm...> -## Created: October 2009 -## Version: 0.1 - -function sys = __sysinv__ (sys) - - [p, m] = size (sys); - - ## TODO: inversion of MIMO TF models - - if (p != 1 || m != 1) - error ("tf: sysinv: MIMO systems not supported yet"); - endif - - den = sys.num; - num = sys.den; - - if (den{1, 1} == 0) # catch case den = 0 - num{1, 1} = tfpoly (0); - den{1, 1} = tfpoly (1); - endif - - sys.num = num; - sys.den = den; - -endfunction \ No newline at end of file Deleted: trunk/octave-forge/main/control/inst/@tf/__sysprune__.m =================================================================== --- trunk/octave-forge/main/control/inst/@tf/__sysprune__.m 2010-09-15 00:13:40 UTC (rev 7722) +++ trunk/octave-forge/main/control/inst/@tf/__sysprune__.m 2010-09-15 00:36:45 UTC (rev 7723) @@ -1,34 +0,0 @@ -## Copyright (C) 2009 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 this program. If not, see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## Submodel extraction and reordering for TF objects. -## This file is part of the Model Abstraction Layer. -## For internal use only. - -## Author: Lukas Reichlin <luk...@gm...> -## Created: October 2009 -## Version: 0.1 - -function sys = __sysprune__ (sys, out_idx, in_idx) - - sys.lti = __lti_prune__ (sys.lti, out_idx, in_idx); - - sys.num = sys.num(out_idx, in_idx); - sys.den = sys.den(out_idx, in_idx); - -endfunction \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |