www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/@cgoptimrunner/private/pGetConstraintNames.m

    function conLabels = pGetConstraintNames(obj, type)
%PGETCONSTRAINTNAMES Get constraint labels
%
%   CONLABELS = PGETCONSTRAINTNAMES(OBJ, TYPE) returns optimization
%   constraint labels of a given TYPE. TYPE is either 'linear' or
%   'nonlinear'.

%   Copyright 2005-2009 The MathWorks, Inc.

% Get the constraints
isl = cellfun(@isLinear, obj.Constraints.Items);
if ~isempty(isl)
    options = getOptimOptions(obj,'full');
    allcon = getConstraints(options);
    if strcmp(type, 'linear')
        logtype = isl;
    else
        logtype = ~isl;
    end
    conLabels = cell(1, length(find(logtype)));
    [conLabels{:}] = deal(allcon(logtype).label);
else
    conLabels = cell(1, 0);
end