# HG changeset patch # User Olaf Till # Date 1287622293 14400 # Node ID 134d357e1c035edf8cd3ef34aa677a6229c5f9dc # Parent a44f979a35ce4a5bf6c8eee4f19f744a398455e3 optimization/optimset.m: Use cell2struct instead of struct to handle cell arrays as options diff -r a44f979a35ce -r 134d357e1c03 scripts/ChangeLog --- a/scripts/ChangeLog Wed Oct 20 20:49:17 2010 -0400 +++ b/scripts/ChangeLog Wed Oct 20 20:51:33 2010 -0400 @@ -1,3 +1,8 @@ +2010-10-20 Olaf Till + + * optimization/optimset.m: Use cell2struct instead of struct to + handle cell arrays as options. + 2010-10-20 John W. Eaton * io/strread.m, optimization/sqp.m, plot/daspect.m, diff -r a44f979a35ce -r 134d357e1c03 scripts/optimization/optimset.m --- a/scripts/optimization/optimset.m Wed Oct 20 20:49:17 2010 -0400 +++ b/scripts/optimization/optimset.m Wed Oct 20 20:51:33 2010 -0400 @@ -76,11 +76,13 @@ retval = old; elseif (rem (nargs, 2) && isstruct (varargin{1})) ## Set values in old from name/value pairs. - retval = optimset (varargin{1}, struct (varargin{2:end})); + pairs = reshape (varargin(2:end), 2, []); + retval = optimset (varargin{1}, cell2struct (pairs(2, :), pairs(1, :), 2)); elseif (rem (nargs, 2) == 0) ## Create struct. Default values are replaced by those specified by ## name/value pairs. - retval = optimset (struct (), struct (varargin{:})); + pairs = reshape (varargin, 2, []); + retval = optimset (struct (), cell2struct (pairs(2, :), pairs(1, :), 2)); else print_usage (); endif