www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/@cgoptimoptions/addOperatingPointSet.m
function obj = addOperatingPointSet(obj, sLabel, vars) %ADDOPERATINGPOINTSET Add an operating point set to the optimization. % OPTIONS = ADDOPERATINGPOINTSET(OPTIONS, LABEL, VARS) adds a placeholder % for an additional operating point set to the optimization. The string % LABEL will be used to refer to the operating point set in the CAGE GUI. % VARS is a (1-by-N) cell array of strings, where N >= 1. Each element % of VARS is a label for a CAGE variable that must appear in the % operating point set that the user chooses. % % See also CGOPTIMOPTIONS/GETOPERATINGPOINTSETS, % CGOPTIMOPTIONS/SETOPERATINGPOINTSMODE, % CGOPTIMOPTIONS/GETOPERATINGPOINTSMODE, % CGOPTIMOPTIONS/REMOVEOPERATINGPOINTSET. % Copyright 2000-2011 The MathWorks, Inc. and Ford Global Technologies, Inc. % Some sanity checks if nargin < 3 error(message('mbc:cgoptimoptions:InvalidArgument7')); end % Check input types [ok, msg] = i_CheckInputs({sLabel, vars}); if ~ok error('mbc:cgoptimoptions:InvalidArgument8',msg); end % Check that the label is unique to other objectives ok = checklabel(obj, sLabel); if ~ok error(message('mbc:cgoptimoptions:NonUniqueLabel4')); end opsmode = getOperatingPointsMode(obj); oppts = obj.operatingpoints.details; N = length(oppts); if any(strcmp(opsmode, {'fixed', 'any'})) ... || (strcmp(opsmode, 'default') && N==0) oppts(N+1).label = sLabel; oppts(N+1).vars = vars; obj.operatingpoints.details = oppts; else warning(message('mbc:cgoptimoptions:InvalidState1')); end %---------------------------------------------------------------------- function [ok, msg] = i_CheckInputs(in) %---------------------------------------------------------------------- ok = false; msg = ''; if ~ischar(in{1}) || isempty(in{1}) msg = 'The label must be a non-empty string.'; elseif ~iscell(in{2}) msg = 'The required variables input must be a cell array of strings.'; elseif ~all(cellfun('isclass', in{2}, 'char')) msg = 'The required variables input must be a cell array of strings.'; elseif ~isempty(in{2}) && ((size(in{2}, 1) ~= 1) || (ndims(in{2}) ~= 2)) msg = 'The required variables input must be a (1-by-N) cell array.'; else ok = true; end