From: <par...@us...> - 2011-11-19 18:01:34
|
Revision: 9139 http://octave.svn.sourceforge.net/octave/?rev=9139&view=rev Author: paramaniac Date: 2011-11-19 18:01:27 +0000 (Sat, 19 Nov 2011) Log Message: ----------- control-devel: allow struct to pass settings 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/hnamodred.m Added Paths: ----------- trunk/octave-forge/extra/control-devel/inst/__opt2cell__.m trunk/octave-forge/extra/control-devel/inst/options.m Removed Paths: ------------- trunk/octave-forge/extra/control-devel/devel/opt2cell.m trunk/octave-forge/extra/control-devel/devel/options.m Deleted: trunk/octave-forge/extra/control-devel/devel/opt2cell.m =================================================================== --- trunk/octave-forge/extra/control-devel/devel/opt2cell.m 2011-11-19 15:43:51 UTC (rev 9138) +++ trunk/octave-forge/extra/control-devel/devel/opt2cell.m 2011-11-19 18:01:27 UTC (rev 9139) @@ -1,12 +0,0 @@ -function c = opt2cell (opt) - - if (! isstruct (opt)) - error ("opt2cell: argument must be a struct"); - endif - - key = fieldnames (opt); - val = struct2cell (opt); - - c = [key.'; val.'](:); # reshape to {key1; val1; key2; val2; ...} - -endfunction \ No newline at end of file Deleted: trunk/octave-forge/extra/control-devel/devel/options.m =================================================================== --- trunk/octave-forge/extra/control-devel/devel/options.m 2011-11-19 15:43:51 UTC (rev 9138) +++ trunk/octave-forge/extra/control-devel/devel/options.m 2011-11-19 18:01:27 UTC (rev 9139) @@ -1,16 +0,0 @@ -function opt = options (varargin) - - if (nargin == 0) - print_usage (); - endif - - if (rem (nargin, 2)) - error ("options: properties and values must come in pairs"); - endif - - key = reshape (varargin(1:2:end-1), [], 1); - val = reshape (varargin(2:2:end), [], 1); - - opt = cell2struct (val, key, 1) - -endfunction \ No newline at end of file Modified: trunk/octave-forge/extra/control-devel/inst/__modred_ab09id__.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__modred_ab09id__.m 2011-11-19 15:43:51 UTC (rev 9138) +++ trunk/octave-forge/extra/control-devel/inst/__modred_ab09id__.m 2011-11-19 18:01:27 UTC (rev 9139) @@ -42,7 +42,9 @@ error ("%smodred: first argument must be an LTI system", method); endif - if (rem (npv, 2)) + if (npv == 1) + varargin = __opt2cell__ (varargin{1}); + elseif (rem (npv, 2)) error ("%smodred: properties and values must come in pairs", method); endif @@ -103,7 +105,7 @@ ## TODO: alphac, alphao, jobc, jobo otherwise - error ("hnamodred: invalid property name"); + warning ("modred: invalid property name ""%s"" ignored", prop); endswitch endfor Copied: trunk/octave-forge/extra/control-devel/inst/__opt2cell__.m (from rev 9138, trunk/octave-forge/extra/control-devel/devel/opt2cell.m) =================================================================== --- trunk/octave-forge/extra/control-devel/inst/__opt2cell__.m (rev 0) +++ trunk/octave-forge/extra/control-devel/inst/__opt2cell__.m 2011-11-19 18:01:27 UTC (rev 9139) @@ -0,0 +1,12 @@ +function c = __opt2cell__ (opt) + + if (! isstruct (opt)) + error ("opt2cell: argument must be a struct"); + endif + + key = fieldnames (opt); + val = struct2cell (opt); + + c = [key.'; val.'](:); # reshape to {key1; val1; key2; val2; ...} + +endfunction \ No newline at end of file Modified: trunk/octave-forge/extra/control-devel/inst/bstmodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/bstmodred.m 2011-11-19 15:43:51 UTC (rev 9138) +++ trunk/octave-forge/extra/control-devel/inst/bstmodred.m 2011-11-19 18:01:27 UTC (rev 9139) @@ -59,7 +59,9 @@ error ("bstmodred: first argument must be an LTI system"); endif - if (rem (nargin-1, 2)) + if (nargin == 2) + varargin = __opt2cell__ (varargin{1}); + elseif (rem (nargin-1, 2)) error ("bstmodred: properties and values must come in pairs"); endif @@ -113,12 +115,10 @@ endswitch otherwise - error ("hnamodred: invalid property name"); + warning ("bstmodred: invalid property name ""%s"" ignored", prop); endswitch endfor - ## TODO: handle job - ## perform model order reduction [ar, br, cr, dr, nr, hsv, ns] = slab09hd (a, b, c, d, dt, scaled, job, nr, ordsel, alpha, beta, \ tol1, tol2); Modified: trunk/octave-forge/extra/control-devel/inst/hnamodred.m =================================================================== --- trunk/octave-forge/extra/control-devel/inst/hnamodred.m 2011-11-19 15:43:51 UTC (rev 9138) +++ trunk/octave-forge/extra/control-devel/inst/hnamodred.m 2011-11-19 18:01:27 UTC (rev 9139) @@ -55,7 +55,9 @@ error ("hnamodred: first argument must be an LTI system"); endif - if (rem (nargin-1, 2)) + if (nargin == 2) + varargin = __opt2cell__ (varargin{1}); + elseif (rem (nargin-1, 2)) error ("hnamodred: properties and values must come in pairs"); endif @@ -136,12 +138,11 @@ endswitch otherwise - error ("hnamodred: invalid property name"); + warning ("hnamodred: invalid property name ""%s"" ignored", prop); endswitch endfor + - ## TODO: handle jobv, jobw, (jobinv) - ## perform model order reduction [ar, br, cr, dr, nr, hsv, ns] = slab09jd (a, b, c, d, dt, scaled, nr, ordsel, alpha, \ jobv, av, bv, cv, dv, \ Copied: trunk/octave-forge/extra/control-devel/inst/options.m (from rev 9138, trunk/octave-forge/extra/control-devel/devel/options.m) =================================================================== --- trunk/octave-forge/extra/control-devel/inst/options.m (rev 0) +++ trunk/octave-forge/extra/control-devel/inst/options.m 2011-11-19 18:01:27 UTC (rev 9139) @@ -0,0 +1,16 @@ +function opt = options (varargin) + + if (nargin == 0) + print_usage (); + endif + + if (rem (nargin, 2)) + error ("options: properties and values must come in pairs"); + endif + + key = reshape (varargin(1:2:end-1), [], 1); + val = reshape (varargin(2:2:end), [], 1); + + opt = cell2struct (val, key, 1) + +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. |