Mercurial > hg > octave-nkf
changeset 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 | a44f979a35ce |
children | 7abc783e202c |
files | scripts/ChangeLog scripts/optimization/optimset.m |
diffstat | 2 files changed, 9 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,8 @@ +2010-10-20 Olaf Till <olaf.till@uni-jena.de> + + * optimization/optimset.m: Use cell2struct instead of struct to + handle cell arrays as options. + 2010-10-20 John W. Eaton <jwe@octave.org> * io/strread.m, optimization/sqp.m, plot/daspect.m,
--- 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