Mercurial > hg > octave-lyh
diff scripts/optimization/optimset.m @ 11121:134d357e1c03
optimization/optimset.m: Use cell2struct instead of struct to handle cell arrays as options
author | Olaf Till <olaf.till@uni-jena.de> |
---|---|
date | Wed, 20 Oct 2010 20:51:33 -0400 |
parents | be55736a0783 |
children | 30f54b3b9953 |
line wrap: on
line diff
--- a/scripts/optimization/optimset.m +++ b/scripts/optimization/optimset.m @@ -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