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

    function obj = setExpression(obj, pExpr)
%SETEXPRESSION Set a new objective expression
%
%  OBJ = SETEXPRESSION(OBJ, PEXPR) sets PEXPR to be the expression that is
%  providing the objective values.

%  Copyright 2005 The MathWorks, Inc. and Ford Global Technologies, Inc.


if isempty(pExpr)
    obj.Expression = mbcpointer(1);
else
    obj.Expression = pExpr;
end

% Check weights are created
if ~isvalid(obj.Weights)
    obj.Weights = pCreateWeightsPtr(obj);
end

% Reset the range of the expression
obj = updateranges(obj);