forked from tholden/gmmtbx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
optset.m
34 lines (30 loc) · 935 Bytes
/
optset.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
% OPTSET Utility to set function options
% USAGE
% optset(funcname,optname,optvalue)
% INPUTS
% funcname : name of function
% optname : name of option
% optval : option value
%
% If optname='defaults' the current setting of the options will be
% cleared. The next time the function is called, the default
% options will be restored.
% Copyright (c) 1997-2002, Paul L. Fackler & Mario J. Miranda
function optvalue = optset(funcname,optname,optvalue)
global options_
funcname = lower( funcname );
optname = lower( optname );
if ~isstruct( options_ )
options_ = struct;
end
if ~isfield( options_, funcname )
options_.( funcname ) = struct;
end
FunctionOptions = options_.( funcname );
FunctionOptions.( optname ) = optvalue;
if strcmp( optname, 'defaults' )
FunctionOptions = rmfield( FunctionOptions, optname );
end
options_.( funcname ) = FunctionOptions;
end