www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/@cgoptimoptions/renameObjective.m
function opts = renameObjective(opts, oldLabel, newLabel) %RENAMEOBJECTIVE Rename an objective % % OPTS = RENAMEOBJECTIVE(OPTS, OLDLABEL, NEWLABEL) renames the % specified objective. % % See also CGOPTIM/RENAMECONSTRAINT % Copyright 2007 The MathWorks, Inc. % Do not allow rename if renameMode is false if ~opts.renameMode error(message('mbc:cgoptimoptions:InvalidState7')); end % Do not allow if the new label is not unique ok = checklabel(opts, newLabel); if ~ok error(message('mbc:cgoptimoptions:NonUniqueLabel7')); end % If here, we should be able to rename the objective idx = getObjectiveIndex(opts, oldLabel); if idx opts.objectives.details(idx).label = newLabel; else error(message('mbc:cgoptimoptions:InvalidState8')); end