# HG changeset patch # User Rik # Date 1316578796 25200 # Node ID cc1fd6a58151b835cad29b1c7d22639b12a93e55 # Parent cb2b57abcc3541cda0b80223591d6c10ff231518 optimset.m: When called with 1 output argument, return a struct with all possible options initialized to []. * optimset.m: When called with 1 output argument, return a struct with all possible options initialized to []. diff --git a/scripts/optimization/optimset.m b/scripts/optimization/optimset.m --- a/scripts/optimization/optimset.m +++ b/scripts/optimization/optimset.m @@ -39,9 +39,8 @@ printf (" %s\n", opts{:}); puts ("\n"); else - ## Return empty structure. - ## We're incompatible with Matlab at this point. - retval = struct (); + ## Return struct with all options initialized to [] + retval = cell2struct (repmat ({[]}, size (opts)), opts, 2); endif elseif (nargs == 1 && ischar (varargin{1})) ## Return defaults for named function. @@ -90,5 +89,9 @@ endfunction + %!assert (optimget (optimset ('tolx', 1e-2), 'tOLx'), 1e-2) %!assert (isfield (optimset ('tolFun', 1e-3), 'TolFun')) + +%!error (optimset ("%NOT_A_REAL_FUNCTION_NAME%")) +