From: <par...@us...> - 2011-12-01 18:30:05
|
Revision: 9237 http://octave.svn.sourceforge.net/octave/?rev=9237&view=rev Author: paramaniac Date: 2011-12-01 18:29:55 +0000 (Thu, 01 Dec 2011) Log Message: ----------- control-devel: use argument handling from bstmodred for all *modred commands Modified Paths: -------------- trunk/octave-forge/extra/control-devel/inst/__modred_ab09id__.m trunk/octave-forge/extra/control-devel/inst/bstmodred.m trunk/octave-forge/extra/control-devel/inst/btamodred.m trunk/octave-forge/extra/control-devel/inst/hnamodred.m trunk/octave-forge/extra/control-devel/inst/spamodred.m Modified: trunk/octave-forge/extra/control-devel/inst/__modred_ab09id__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__modred_ab09id__.m 2011-12-01 16:55:42 UTC (rev 9236) +++ trunk/octave-forge/extra/control-devel/inst/__modred_ab09id__.m 2011-12-01 18:29:55 UTC (rev 9237) @@ -42,9 +42,22 @@ error ("%smodred: first argument must be an LTI system", method); endif - if (npv == 1) - varargin = __opt2cell__ (varargin{1}); - elseif (rem (npv, 2)) + if (nargin > 2) # *modred (G, ...) + if (is_real_scalar (varargin{1})) # *modred (G, nr) + varargin = horzcat (varargin(2:end), {"order"}, varargin(1)); + endif + if (isstruct (varargin{1})) # *modred (G, opt, ...), *modred (G, nr, opt, ...) + varargin = horzcat (__opt2cell__ (varargin{1}), varargin(2:end)); + endif + ## order placed at the end such that nr from *modred (G, nr, ...) + ## and *modred (G, nr, opt, ...) overrides possible nr's from + ## key/value-pairs and inside opt struct (later keys override former keys, + ## nr > key/value > opt) + endif + + npv = numel (varargin); # number of properties and values + + if (rem (npv, 2)) error ("%smodred: properties and values must come in pairs", method); endif Modified: trunk/octave-forge/extra/control-devel/inst/bstmodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/bstmodred.m 2011-12-01 16:55:42 UTC (rev 9236) +++ trunk/octave-forge/extra/control-devel/inst/bstmodred.m 2011-12-01 18:29:55 UTC (rev 9237) @@ -243,9 +243,9 @@ ## nr > key/value > opt) endif - narg = numel (varargin); + npv = numel (varargin); # number of properties and values - if (rem (narg, 2)) + if (rem (npv, 2)) error ("bstmodred: keys and values must come in pairs"); endif @@ -262,7 +262,7 @@ job = 1; ## handle properties and values - for k = 1 : 2 : narg + for k = 1 : 2 : npv prop = lower (varargin{k}); val = varargin{k+1}; switch (prop) Modified: trunk/octave-forge/extra/control-devel/inst/btamodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/btamodred.m 2011-12-01 16:55:42 UTC (rev 9236) +++ trunk/octave-forge/extra/control-devel/inst/btamodred.m 2011-12-01 18:29:55 UTC (rev 9237) @@ -16,9 +16,11 @@ ## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn{Function File} {[@var{sysr}, @var{nr}] =} btamodred (@var{sys}) -## @deftypefnx{Function File} {[@var{sysr}, @var{nr}] =} btamodred (@var{sys}, @dots{}) -## @deftypefnx{Function File} {[@var{sysr}, @var{nr}] =} btamodred (@var{sys}, @var{opt}) +## @deftypefn{Function File} {[@var{Gr}, @var{nr}] =} btamodred (@var{G}, @dots{}) +## @deftypefnx{Function File} {[@var{Gr}, @var{nr}] =} btamodred (@var{G}, @var{nr}, @dots{}) +## @deftypefnx{Function File} {[@var{Gr}, @var{nr}] =} btamodred (@var{G}, @var{opt}, @dots{}) +## @deftypefnx{Function File} {[@var{Gr}, @var{nr}] =} btamodred (@var{G}, @var{nr}, @var{opt}, @dots{}) +## ## Model order reduction by frequency weighted optimal Hankel-norm approximation method. ## ## @strong{Inputs} Modified: trunk/octave-forge/extra/control-devel/inst/hnamodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/hnamodred.m 2011-12-01 16:55:42 UTC (rev 9236) +++ trunk/octave-forge/extra/control-devel/inst/hnamodred.m 2011-12-01 18:29:55 UTC (rev 9237) @@ -16,9 +16,11 @@ ## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn{Function File} {[@var{sysr}, @var{info}] =} hnamodred (@var{sys}) -## @deftypefnx{Function File} {[@var{sysr}, @var{info}] =} hnamodred (@var{sys}, @dots{}) -## @deftypefnx{Function File} {[@var{sysr}, @var{info}] =} hnamodred (@var{sys}, @var{opt}) +## @deftypefn{Function File} {[@var{Gr}, @var{info}] =} hnamodred (@var{G}, @dots{}) +## @deftypefnx{Function File} {[@var{Gr}, @var{info}] =} hnamodred (@var{G}, @var{nr}, @dots{}) +## @deftypefnx{Function File} {[@var{Gr}, @var{info}] =} hnamodred (@var{G}, @var{opt}, @dots{}) +## @deftypefnx{Function File} {[@var{Gr}, @var{info}] =} hnamodred (@var{G}, @var{nr}, @var{opt}, @dots{}) +## ## Model order reduction by frequency weighted optimal Hankel-norm approximation method. ## ## @strong{Inputs} @@ -57,9 +59,22 @@ error ("hnamodred: first argument must be an LTI system"); endif - if (nargin == 2) - varargin = __opt2cell__ (varargin{1}); - elseif (rem (nargin-1, 2)) + if (nargin > 1) # hnamodred (G, ...) + if (is_real_scalar (varargin{1})) # hnamodred (G, nr) + varargin = horzcat (varargin(2:end), {"order"}, varargin(1)); + endif + if (isstruct (varargin{1})) # hnamodred (G, opt, ...), hnamodred (G, nr, opt, ...) + varargin = horzcat (__opt2cell__ (varargin{1}), varargin(2:end)); + endif + ## order placed at the end such that nr from hnamodred (G, nr, ...) + ## and hnamodred (G, nr, opt, ...) overrides possible nr's from + ## key/value-pairs and inside opt struct (later keys override former keys, + ## nr > key/value > opt) + endif + + npv = numel (varargin); # number of properties and values + + if (rem (npv, 2)) error ("hnamodred: properties and values must come in pairs"); endif @@ -80,7 +95,7 @@ nr = 0; ## handle properties and values - for k = 1 : 2 : (nargin-1) + for k = 1 : 2 : npv prop = lower (varargin{k}); val = varargin{k+1}; switch (prop) Modified: trunk/octave-forge/extra/control-devel/inst/spamodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/spamodred.m 2011-12-01 16:55:42 UTC (rev 9236) +++ trunk/octave-forge/extra/control-devel/inst/spamodred.m 2011-12-01 18:29:55 UTC (rev 9237) @@ -16,9 +16,11 @@ ## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn{Function File} {[@var{sysr}, @var{nr}] =} spamodred (@var{sys}) -## @deftypefnx{Function File} {[@var{sysr}, @var{nr}] =} spamodred (@var{sys}, @dots{}) -## @deftypefnx{Function File} {[@var{sysr}, @var{nr}] =} spamodred (@var{sys}, @var{opt}) +## @deftypefn{Function File} {[@var{Gr}, @var{nr}] =} spamodred (@var{G}, @dots{}) +## @deftypefnx{Function File} {[@var{Gr}, @var{nr}] =} spamodred (@var{G}, @var{nr}, @dots{}) +## @deftypefnx{Function File} {[@var{Gr}, @var{nr}] =} spamodred (@var{G}, @var{opt}, @dots{}) +## @deftypefnx{Function File} {[@var{Gr}, @var{nr}] =} spamodred (@var{G}, @var{nr}, @var{opt}, @dots{}) +## ## Model order reduction by frequency weighted optimal Hankel-norm approximation method. ## ## @strong{Inputs} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |