1 ## Copyright (C) 2008-2012 Jaroslav Hajek
2 ## Copyright (C) 2009 VZLU Prague
4 ## This file is part of Octave.
6 ## Octave is free software; you can redistribute it and/or modify it
7 ## under the terms of the GNU General Public License as published by
8 ## the Free Software Foundation; either version 3 of the License, or (at
9 ## your option) any later version.
11 ## Octave is distributed in the hope that it will be useful, but
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 ## General Public License for more details.
16 ## You should have received a copy of the GNU General Public License
17 ## along with Octave; see the file COPYING. If not, see
18 ## <http://www.gnu.org/licenses/>.
21 ## @deftypefn {Function File} {} optimget (@var{options}, @var{parname})
22 ## @deftypefnx {Function File} {} optimget (@var{options}, @var{parname}, @var{default})
23 ## Return a specific option from a structure created by
24 ## @code{optimset}. If @var{parname} is not a field of the @var{options}
25 ## structure, return @var{default} if supplied, otherwise return an
29 function retval = optimget (options, parname, default)
31 if (nargin < 2 || nargin > 4 || ! isstruct (options) || ! ischar (parname))
35 opts = __all_opts__ ();
36 idx = lookup (tolower (opts), tolower (parname), "m");
41 warning ("unrecognized option: %s", parname);
43 if (isfield (options, parname))
44 retval = options.(parname);