www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/@cgoptim/initOpPointVariables.m

    function optim = initOpPointVariables(optim,OpPointVariables)
%INITOPPOINTVARIABLES initialize operating point variables for optim
%    optim = initOpPointVariables(optim,OpPointVariables);
%    optim = initOpPointVariables(optim);
%    By default, the operating point variables are set to the first two
%    fixed variables. The operating variables are set to empty if there are
%    not two fixed variables. The mode variable is set from the mode input
%    to a composite model.

%  Copyright 2009-2011 The MathWorks, Inc.

DS = optim.oppoints;
% set up mode variable for current optimization
pMod = getPrimaryExpression(optim);
if ~isempty(pMod) && ~isnull(pMod)
    [SwitchModel,pInp] = getSwitchModel(pMod.info);
    if ~isempty(SwitchModel) && isMultiModal(SwitchModel)
        % mode variable is last input
        DS = editModeVariable(DS,pInp(end));
    end
end

if nargin>1 
    DS = editOpPointVariables(DS,OpPointVariables);
elseif isempty(DS.OpPointVariables)
    % Get all of the fixed variables that are real project items
    pfixed = getfixedvalues(optim);
    pfixed = setdiff(pfixed,getInternalPtrs(optim));
    % remove mode variable
    pfixed = setdiff(pfixed,DS.ModeVariable);

    if length(pfixed)>=2
        % Find some defaults from the first data set if we can
        % Use the first two from the ones we found
        DS = editOpPointVariables(DS,pfixed(1:2));
    end
end
optim.oppoints = DS;