From: <par...@us...> - 2010-08-29 23:49:37
|
Revision: 7603 http://octave.svn.sourceforge.net/octave/?rev=7603&view=rev Author: paramaniac Date: 2010-08-29 23:49:31 +0000 (Sun, 29 Aug 2010) Log Message: ----------- control: simplify input argument check Modified Paths: -------------- trunk/octave-forge/main/control/inst/isdetectable.m trunk/octave-forge/main/control/inst/isstabilizable.m Modified: trunk/octave-forge/main/control/inst/isdetectable.m =================================================================== --- trunk/octave-forge/main/control/inst/isdetectable.m 2010-08-29 23:01:44 UTC (rev 7602) +++ trunk/octave-forge/main/control/inst/isdetectable.m 2010-08-29 23:49:31 UTC (rev 7603) @@ -40,21 +40,17 @@ function retval = isdetectable (a, c = [], tol = [], dflg = 0) - if (nargin < 1) + if (nargin < 1 || nargin > 4) print_usage (); - elseif (isa (a, "lti")) - ## system form - if (nargin == 2) - tol = c; - elseif (nargin > 2) + elseif (isa (a, "lti")) # system passed + if (nargin > 2) print_usage (); endif + tol = c; dflg = isdt (a); [a, b, c] = ssdata (a); - else - if (nargin > 4 || nargin == 1) - print_usage (); - endif + elseif (nargin == 1) # a,b arguments sent directly + print_usage (); endif retval = isstabilizable (a.', c.', tol, dflg); Modified: trunk/octave-forge/main/control/inst/isstabilizable.m =================================================================== --- trunk/octave-forge/main/control/inst/isstabilizable.m 2010-08-29 23:01:44 UTC (rev 7602) +++ trunk/octave-forge/main/control/inst/isstabilizable.m 2010-08-29 23:49:31 UTC (rev 7603) @@ -49,21 +49,17 @@ function retval = isstabilizable (a, b = [], tol = [], dflg = 0) - if (nargin < 1) + if (nargin < 1 || nargin > 4) print_usage (); elseif (isa (a, "lti")) # system passed - if (nargin == 2) - tol = b; # get tolerance - elseif (nargin > 2) + if (nargin > 2) print_usage (); endif - disc = isdt(a); + tol = b; + dflg = isdt (a); [a, b] = ssdata (a); - else # a,b arguments sent directly - if (nargin > 4 || nargin == 1) - print_usage (); - endif - disc = dflg; + elseif (nargin == 1) # a,b arguments sent directly + print_usage (); endif if (isempty (tol)) @@ -88,29 +84,29 @@ specflag = 0; for k = 1 : n - if (! disc) - ## Continuous time case - rL = real (L(k)); - if (rL >= 0) + if (dflg) + ## Discrete time case + rL = abs (L(k)); + if (rL >= 1) H = [eye(n)*L(k)-a, b]; f = (rank (H, tol) == n); if (f == 0) retval = 0; - if (rL == 0) - specflag = 1; + if (rL == 1) + specflag = 1; endif endif endif else - ## Discrete time case - rL = abs (L(k)); - if (rL >= 1) + ## Continuous time case + rL = real (L(k)); + if (rL >= 0) H = [eye(n)*L(k)-a, b]; f = (rank (H, tol) == n); if (f == 0) retval = 0; - if (rL == 1) - specflag = 1; + if (rL == 0) + specflag = 1; endif endif endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |