changeset 13183:cc1fd6a58151

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 [].
author Rik <octave@nomad.inbox5.com>
date Tue, 20 Sep 2011 21:19:56 -0700
parents cb2b57abcc35
children 8a124aeb7ded
files scripts/optimization/optimset.m
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/optimization/optimset.m	Tue Sep 20 19:42:13 2011 -0700
+++ b/scripts/optimization/optimset.m	Tue Sep 20 21:19:56 2011 -0700
@@ -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%"))
+