www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/@cgoptim/changeFreeVariables.m
function optim = changeFreeVariables(optim,pFree) %CHANGEFREEVARIABLES in optimization. % % optim = changeFreeVariables(optim,pFree) % This routine assumes that free variables can be arbitrarily defined for % the algorithm (add,remove,rename). It probably only works well when % changing free variables to fixed or vice versa. % % Warnings may be produced if there are objectives or constraints that no % longer depend on free variables. % Copyright 2009 The MathWorks, Inc. and Ford Global Technologies, Inc. % Set free variables in optimization opts = getSetup(optim); % setup free variables lbls = getFreeVariables(opts); for i=1:length(lbls) % remove all free variables opts = removeFreeVariable(opts, lbls{i}); end for i=1:length(pFree) % add all free variables opts = addFreeVariable(opts, pFree(i).getname); end optim = setSetup(optim,opts); optim = set(optim,'values',pFree);