www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/@cgoptimstore/getObjectiveType.m
function objType = getObjectiveType(optimstore, varargin) %GETOBJECTIVETYPE Return the objective type % OBJTYPE = GETOBJECTIVETYPE(OPTIMSTORE) returns the objective type of % all the objectives in the optimization. A 1-by-NOBJ cell array is % returned, each element being 'min', 'max' or 'helper'. % % OBJTYPE = GETOBJECTIVETYPE(OPTIMSTORE, OBJLABELS) returns the objective % type for the defined objectives. % % See also: CGOPTIMSTORE/GETOBJECTIVES. % Copyright 2005-2009 The MathWorks, Inc. and Ford Global Technologies, Inc. % Get the required objective labels nObj = getNumObjectives(optimstore); if nargin > 1 indx = pGetItemIndex(optimstore, varargin{1}, 'objective'); else indx = 1:length(nObj); end % Get the objective type for each required label cnObj = cumsum(nObj); objType = getObjectiveTypes(optimstore.OptimRunner); objType = objType(cnObj(indx)); % Replace 'Maximize' and 'Minimize' with 'max' and 'min' for uniformity objType = strrep(objType, 'Maximize', 'max'); objType = strrep(objType, 'Minimize', 'min');