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

    function ok = checklabel(opt, label)
%CHECKLABEL Check to see if the supplied label is unique,
%
%   OK = CHECKLABEL(OPTIONS, LABEL) is a private helper function that
%   checks whether a supplied label is unique.

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



% Labels are checked for uniqueness against all other labels in the
% optimization

% Free variables
ok = ~any(  strcmp( label,getFreeVariables( opt ) ) );

if ok
    % Objectives
    info = getObjectives(opt);
    if ~isempty(info)
        ok = ~any(  strcmp( label,{ info( : ).label } ) );
    end
end

if ok
    % Linear Constraints
    info = getLinearConstraints(opt);
    if ~isempty(info)
        ok = ~any(  strcmp( label,{ info( : ).label } ) );
    end
end

if ok
    % Model Constraints
    info = getModelConstraints(opt);
    if ~isempty(info)
        ok = ~any(  strcmp( label,{ info( : ).label } ) );
    end
end

if ok
    % Operating Point sets
    info = getOperatingPointSets(opt);
    if ~isempty(info)
        ok = ~any(  strcmp( label,{ info( : ).label } ) );
    end
end

if ok
    % Parameters
    info = getParameters(opt);
    if ~isempty(info) && isstruct(info)
        ok = ~any(  strcmp( label,{ info( : ).label } ) );
    end
end