From: <par...@us...> - 2011-09-03 19:42:11
|
Revision: 8489 http://octave.svn.sourceforge.net/octave/?rev=8489&view=rev Author: paramaniac Date: 2011-09-03 19:42:05 +0000 (Sat, 03 Sep 2011) Log Message: ----------- control: add d2c (incomplete) Modified Paths: -------------- trunk/octave-forge/main/control/inst/@ss/__c2d__.m trunk/octave-forge/main/control/inst/@tf/__c2d__.m trunk/octave-forge/main/control/inst/ltimodels.m Added Paths: ----------- trunk/octave-forge/main/control/inst/@frd/__d2c__.m trunk/octave-forge/main/control/inst/@lti/d2c.m trunk/octave-forge/main/control/inst/@ss/__d2c__.m trunk/octave-forge/main/control/inst/@tf/__d2c__.m Added: trunk/octave-forge/main/control/inst/@frd/__d2c__.m =================================================================== --- trunk/octave-forge/main/control/inst/@frd/__d2c__.m (rev 0) +++ trunk/octave-forge/main/control/inst/@frd/__d2c__.m 2011-09-03 19:42:05 UTC (rev 8489) @@ -0,0 +1,31 @@ +## 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 -*- +## Convert the discrete FRD object into its continuous-time equivalent. + +## Author: Lukas Reichlin <luk...@gm...> +## Created: September 2011 +## Version: 0.1 + +function sys = __d2c__ (sys, tsam, method = "zoh") + + error ("frd: d2c: conversion not possible"); + + ## NOTE: changing just the sampling time wouldn't make sense here + +endfunction \ No newline at end of file Added: trunk/octave-forge/main/control/inst/@lti/d2c.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/d2c.m (rev 0) +++ trunk/octave-forge/main/control/inst/@lti/d2c.m 2011-09-03 19:42:05 UTC (rev 8489) @@ -0,0 +1,45 @@ +## 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{sys} =} d2c (@var{sys}) +## @deftypefnx {Function File} {@var{sys} =} d2c (@var{sys}, @var{method}) +## Convert the discrete lti model into its continuous-time equivalent. +## @end deftypefn + +## Author: Lukas Reichlin <luk...@gm...> +## Created: September 2011 +## Version: 0.1 + +function sys = d2c (sys, method = "std") + + if (nargin == 0 || nargin > 2) + print_usage (); + endif + + if (! isa (sys, "lti")) + error ("d2c: first argument is not an lti model"); + endif + + if (! ischar (method)) + error ("c2d: second argument is not a string"); + endif + + sys = __d2c__ (sys, sys.tsam, method); + sys.tsam = 0; + +endfunction \ No newline at end of file Modified: trunk/octave-forge/main/control/inst/@ss/__c2d__.m =================================================================== --- trunk/octave-forge/main/control/inst/@ss/__c2d__.m 2011-09-03 18:50:35 UTC (rev 8488) +++ trunk/octave-forge/main/control/inst/@ss/__c2d__.m 2011-09-03 19:42:05 UTC (rev 8489) @@ -1,4 +1,4 @@ -## Copyright (C) 2009 Lukas F. Reichlin +## Copyright (C) 2009, 2011 Lukas F. Reichlin ## ## This file is part of LTI Syncope. ## @@ -16,11 +16,11 @@ ## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## Convert the continuous SS model into its discrete time equivalent. +## Convert the continuous SS model into its discrete-time equivalent. ## Author: Lukas Reichlin <luk...@gm...> ## Created: October 2009 -## Version: 0.1 +## Version: 0.2 function sys = __c2d__ (sys, tsam, method = "zoh") @@ -58,7 +58,7 @@ [sys.a, sys.b, sys.c, sys.d] = slab04md (sys.a, sys.b, sys.c, sys.d, 1, 2/tsam, false); otherwise - error ("ss: c2d: %s is an invalid method", method); + error ("ss: c2d: %s is an invalid or missing method", method); endswitch Added: trunk/octave-forge/main/control/inst/@ss/__d2c__.m =================================================================== --- trunk/octave-forge/main/control/inst/@ss/__d2c__.m (rev 0) +++ trunk/octave-forge/main/control/inst/@ss/__d2c__.m 2011-09-03 19:42:05 UTC (rev 8489) @@ -0,0 +1,65 @@ +## 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 -*- +## Convert the discrete SS model into its continuous-time equivalent. + +## Author: Lukas Reichlin <luk...@gm...> +## Created: September 2011 +## Version: 0.1 + +function sys = __d2c__ (sys, tsam, method = "zoh") + + switch (method) + case {"zoh", "std"} + if (! isempty (sys.e)) + if (rcond (sys.e) < eps) + error ("ss: d2c: zero-order hold method requires proper system"); + else + sys.a = sys.e \ sys.a; + sys.b = sys.e \ sys.b; + sys.e = []; # require ordinary state-space model + endif + endif + + [n, m] = size (sys.b); # n: states, m: inputs + + ## TODO: use SLICOT MB05OD + tmp = expm ([sys.a*tsam, sys.b*tsam; zeros(m, n+m)]); + + sys.a = tmp (1:n, 1:n); # F + sys.b = tmp (1:n, n+(1:m)); # G + + case {"tustin", "bilin"} + if (! isempty (sys.e)) + if (rcond (sys.e) < eps) + error ("ss: d2c: tustin method requires proper system"); + else + sys.a = sys.e \ sys.a; + sys.b = sys.e \ sys.b; + sys.e = []; # require ordinary state-space model + endif + endif + + [sys.a, sys.b, sys.c, sys.d] = slab04md (sys.a, sys.b, sys.c, sys.d, 1, 2/tsam, true); + + otherwise + error ("ss: d2c: %s is an invalid or missing method", method); + + endswitch + +endfunction \ No newline at end of file Modified: trunk/octave-forge/main/control/inst/@tf/__c2d__.m =================================================================== --- trunk/octave-forge/main/control/inst/@tf/__c2d__.m 2011-09-03 18:50:35 UTC (rev 8488) +++ trunk/octave-forge/main/control/inst/@tf/__c2d__.m 2011-09-03 19:42:05 UTC (rev 8489) @@ -16,7 +16,7 @@ ## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## Convert the continuous TF model into its discrete time equivalent. +## Convert the continuous TF model into its discrete-time equivalent. ## Author: Lukas Reichlin <luk...@gm...> ## Created: October 2009 Added: trunk/octave-forge/main/control/inst/@tf/__d2c__.m =================================================================== --- trunk/octave-forge/main/control/inst/@tf/__d2c__.m (rev 0) +++ trunk/octave-forge/main/control/inst/@tf/__d2c__.m 2011-09-03 19:42:05 UTC (rev 8489) @@ -0,0 +1,29 @@ +## 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 -*- +## Convert the discrete TF model into its continuous-time equivalent. + +## Author: Lukas Reichlin <luk...@gm...> +## Created: September 2011 +## Version: 0.1 + +function sys = __d2c__ (sys, tsam, method = "zoh") + + error ("tf: d2c: not implemented yet"); + +endfunction \ No newline at end of file Modified: trunk/octave-forge/main/control/inst/ltimodels.m =================================================================== --- trunk/octave-forge/main/control/inst/ltimodels.m 2011-09-03 18:50:35 UTC (rev 8488) +++ trunk/octave-forge/main/control/inst/ltimodels.m 2011-09-03 19:42:05 UTC (rev 8489) @@ -1297,3 +1297,25 @@ %! Me = [Ae, Be; Ce, De]; %! %!assert (Mo, Me, 1e-4); + + +## bilinear transformation +%!shared Mo, Me +%! A = [ 1.0 0.5 +%! 0.5 1.0 ]; +%! +%! B = [ 0.0 -1.0 +%! 1.0 0.0 ]; +%! +%! C = [ -1.0 0.0 +%! 0.0 1.0 ]; +%! +%! D = [ 1.0 0.0 +%! 0.0 -1.0 ]; +%! +%! [Ao, Bo, Co, Do] = ssdata (d2c (c2d (ss (A, B, C, D), 2, "tustin"), "tustin")); +%! +%! Mo = [Ao, Bo; Co, Do]; +%! Me = [A, B; C, D]; +%! +%!assert (Mo, Me, 1e-4); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |