www.gusucode.com > mbcexpr 工具箱 matlab 源码程序 > mbcexpr/@cgexprgroup/addOutput.m
function obj = addOutput(obj, newIdx) %ADDOUTPUT Add additional outputs to the expression chain % % OBJ = ADDOUTPUT(OBJ, NEWIDX) specifes that the expressions at the indices % NEWIDX in the static chain should be used as output expressions. % Copyright 2000-2009 The MathWorks, Inc. and Ford Global Technologies, Inc. % Check that newIdx is within range if any(newIdx>length(obj.ExprArray)) error(message('mbc:cgexprgroup:InvalidArgument')); end if ~ismember(newIdx,obj.Outports) % Append output indices obj.Outports = [obj.Outports, newIdx]; % Set the max usage to numExpr+1 to prevent premature cleanup of values obj.MaxIndices(newIdx) = length(obj.ExprArray)+1; % Calculate the required chain parts for the output obj.OutportRequiredIndices = ... [obj.OutportRequiredIndices, pGetEvaluationIndices(obj.InputIndices, newIdx)]; end