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

    function obj = setConstraintsMode(obj, sMode)
%SETCONSTRAINTSMODE Set how the optimization constraints are to be used.
%   OPTIONS = SETCONSTRAINTSMODE(OPTIONS, MODESTR) sets the mode that
%   governs how the user will be allowed to set up constraints for the
%   optimization in the CAGE GUI.  When MODESTR = 'any', the user will be
%   allowed to add any number of constraints.   When MODESTR = 'fixed', the
%   user will only be allowed to edit the constraints that are added by the
%   user-defined optimization function.
%
%   See also CGOPTIMOPTIONS/GETCONSTRAINTSMODE,
%            CGOPTIMOPTIONS/ADDLINEARCONSTRAINT,
%            CGOPTIMOPTIONS/ADDMODELCONSTRAINT.

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


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

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

obj.constraints.mode = sMode;



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

ok = false; msg = '';

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