www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/@cgoptimoptions/setFreeVariablesMode.m

    function obj = setFreeVariablesMode(obj, sMode)
%SETFREEVARIABLESMODE Set how the optimization free variables are used.
%   OPTIONS = SETFREEVARIABLESMODE(OPTIONS, MODESTR) sets the mode that
%   governs how the user will be allowed to set up free variables for the
%   optimization in the CAGE GUI.  When MODESTR = 'any', the user will be
%   allowed to add any number of free variables.   When MODESTR = 'fixed',
%   the user will only be allowed to use the number of free variables that
%   are added by the user-defined optimization function.
%
%   See also CGOPTIMOPTIONS/GETFREEVARIABLESMODE,
%            CGOPTIMOPTIONS/ADDFREEVARIABLE.

%  Copyright 2000-2004 The MathWorks, Inc. and Ford Global Technologies, Inc.


if nargin < 2
    error(message('mbc:cgoptimoptions:InvalidArgument25'));
end

% Check input types
[ok, msg] = i_CheckInputs(sMode);
if ~ok
    error('mbc:cgoptimoptions:InvalidArgument26', msg);
end

obj.freevariables.mode = sMode;


%----------------------------------------------------------------------
function [ok, msg] = i_CheckInputs(in)
%----------------------------------------------------------------------

ok = true;
msg = '';

if ~ischar(in) || isempty(in) || ~any(strcmp(in, {'any', 'fixed'}))
    ok = false;
    msg = 'The mode must be either ''any'' or ''fixed''.';
end