www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/@cgoptimrunner/getObjectiveNames.m
function objLabels = getObjectiveNames(obj, type) %GETOBJECTIVENAMES Get the objective labels % % CONLABELS = GETCONSTRAINTNAMES(OBJ, TYPE) returns optimization % objective labels of a given TYPE. TYPE is either 'all, 'point' or % 'sum'. % % See also CGOPTIMRUNNER/GETCONSTRAINTNAMES % Copyright 2005-2009 The MathWorks, Inc. % Get all objectives if type not specified if nargin < 2 type = 'all'; end % Get objective labels NOBJ = length(obj.Objectives.Items); issum = cellfun(@isa, obj.Objectives.Items, repmat({'cgsumobjective'}, 1, NOBJ)); ispoint = ~issum; % Get the required objectives if strcmp(type, 'all') idx = true(1, NOBJ); elseif strcmp(type, 'sum') idx = issum; else idx = ispoint; end idx = find(idx); if ~isempty(idx) options = getOptimOptions(obj,'full'); allobj = getObjectives(options); objLabels = cell(1, length(idx)); [objLabels{:}] = deal(allobj(idx).label); else objLabels = cell(1, 0); end