www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/@cgoptim/getConstraintEnabled.m
function enstate = getConstraintEnabled(optim, label) %GETCONSTRAINTENABLED Return whether constraints are enabled or not. % % ENSTATE = GETCONSTRAINTENABLED(OPTIM, LABEL) returns the enable state % for the specified constraint label. % % ENSTATE = GETCONSTRAINTENABLED(OPTIM, CELLLABEL) returns the enable % state for the constraints referenced by the labels in CELLLABEL. % % ENSTATE = GETCONSTRAINTENABLED(OPTIM) returns the enable state for all % of the constraint objects. % Copyright 2006 The MathWorks, Inc. if nargin>1 if ischar(label) || iscellstr(label) ind = getConstraintIndex(optim.OptimSetup, label); elseif isnumeric(label) && label>0 && label<=numConstraints(optim.OptimSetup) ind = label; else ind = 0; end if ind==0 error(message('mbc:cgoptim:InvalidLabel')); else % Return the requested enabled states enstate = optim.ConstraintEnabled(ind); end else % Return all enable states enstate = optim.ConstraintEnabled; end