From: <par...@us...> - 2010-12-27 21:38:30
|
Revision: 8042 http://octave.svn.sourceforge.net/octave/?rev=8042&view=rev Author: paramaniac Date: 2010-12-27 21:38:23 +0000 (Mon, 27 Dec 2010) Log Message: ----------- control: avoid duplicate code Modified Paths: -------------- trunk/octave-forge/main/control/inst/@lti/isstable.m trunk/octave-forge/main/control/inst/isstabilizable.m Added Paths: ----------- trunk/octave-forge/main/control/inst/__is_stable__.m Modified: trunk/octave-forge/main/control/inst/@lti/isstable.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/isstable.m 2010-12-27 16:26:44 UTC (rev 8041) +++ trunk/octave-forge/main/control/inst/@lti/isstable.m 2010-12-27 21:38:23 UTC (rev 8042) @@ -1,4 +1,4 @@ -## Copyright (C) 2009 Lukas F. Reichlin +## Copyright (C) 2009, 2010 Lukas F. Reichlin ## ## This file is part of LTI Syncope. ## @@ -23,7 +23,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: October 2009 -## Version: 0.1 +## Version: 0.2 function bool = isstable (sys, tol = 0) @@ -32,11 +32,8 @@ endif eigw = pole (sys); + ct = isct (sys); - if (isct (sys)) - bool = all (real (eigw) < -tol*(1 + abs (eigw))); - else - bool = all (abs (eigw) < 1 - tol); - endif + bool = __is_stable__ (eigw, ct, tol); endfunction \ No newline at end of file Added: trunk/octave-forge/main/control/inst/__is_stable__.m =================================================================== --- trunk/octave-forge/main/control/inst/__is_stable__.m (rev 0) +++ trunk/octave-forge/main/control/inst/__is_stable__.m 2010-12-27 21:38:23 UTC (rev 8042) @@ -0,0 +1,33 @@ +## Copyright (C) 2010 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 -*- +## Determine whether all poles in a vector are stable. + +## Author: Lukas Reichlin <luk...@gm...> +## Created: December 2010 +## Version: 0.1 + +function bool = __is_stable__ (eigw, ct = true, tol = 0) + + if (ct) # continuous-time + bool = all (real (eigw) < -tol*(1 + abs (eigw))); + else # discrete-time + bool = all (abs (eigw) < 1 - tol); + endif + +endfunction \ No newline at end of file Modified: trunk/octave-forge/main/control/inst/isstabilizable.m =================================================================== --- trunk/octave-forge/main/control/inst/isstabilizable.m 2010-12-27 16:26:44 UTC (rev 8041) +++ trunk/octave-forge/main/control/inst/isstabilizable.m 2010-12-27 21:38:23 UTC (rev 8042) @@ -73,7 +73,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: October 2009 -## Version: 0.3 +## Version: 0.3.1 function bool = isstabilizable (a, b = [], e = [], tol = [], dflg = 0) @@ -124,10 +124,6 @@ endif ## check whether uncontrollable poles are stable - if (dflg) - bool = all (abs (eigw) < 1 - tol); - else - bool = all (real (eigw) < -tol*(1 + abs (eigw))); - endif + bool = __is_stable__ (eigw, ! dflg, tol); endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |