www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/@cgoptimnode/setOutput.m

    function obj = setOutput(obj, pOut, idx)
%SETOUTPUT Set a new pointer as an output
%
%   OBJ = SETOUTPUT(OBJ, POUT) sets the list of pointers POUT as the
%   outputs for the optimization node.  
%
%   OBJ = SETOUTPUT(OBJ, POUT, IDX) sets the IDX-th outputs.  The number of
%   elements in POUT and IDX must be equal.

%   Copyright 2005 The MathWorks, Inc.


if nargin<3
    idx = 1:length(obj.OutputData);
end

obj.OutputData(idx) = pOut;
xregpointer(obj);

% Update output nodes
pChild = children(obj);
objChild = infoarray(pChild);
for n = idx
    setdata(objChild{n}, pOut(n));
end