www.gusucode.com > mbctools 工具箱 matlab 源码程序 > mbctools/@mdevtestplan/AddResponse.m
function pResponses = AddResponse(T,VarName,varargin) %ADDRESPONSE add a new response model to test plan % % Default Model : pResponses= AddResponse(T,VarName); % One-stage model : pResponses= AddResponse(T,VarName,Model); % Two-stage model : pResponses= AddResponse(T,VarName,LocalModel,GlobalModel,DatumType); % % Inputs % T : mdevtestplan object % VarName : name of variable for output % Model : one-stage model object % LocalModel : localmod object (use default if empty) % GlobalModel : Response Feature model object (use default if empty) % DatumType : 0=None, 1=Maximum, 2=Minimum, 3=Linked % Copyright 2000-2008 The MathWorks, Inc. and Ford Global Technologies, Inc. if numstages(T)==1 % one-stage models if length(varargin)>1 error(message('mbc:mdevtestplan:InvalidArgument1')); end G= getModel(T.DesignDev); m= MakeGlobalModel(G,varargin{:}); else % two-stage models if length(varargin)>5 error(message('mbc:mdevtestplan:InvalidArgument2')); end m= MakeTwoStage(T,varargin{:}); end D = DataLink(T); if ~any( strcmp(VarName,get(D,'Name')) ) error(message('mbc:mdevtestplan:InvalidValue5', VarName)) end % update response name out= getOutput(m); out.Name= VarName; out.Symbol= VarName; m= setOutput(m,out); % Add model to list to be made T.Responses= [T.Responses {m}]; nResponses= numChildren(T); % make response models T= MakeResponseModels(T); if numChildren(T)>nResponses % return pointer to new response nodes pResponses= children(T,nResponses+1:numChildren(T)); else % return a null pointer pResponses = xregpointer; end % MakeTwoStage function TS= MakeTwoStage(T,LocalModel,GlobalModel,DatumType) L= getModel(T.DesignDev,1); L= L{1}; if nargin>3 set(L,'DatumType',DatumType); else DatumType= get(L,'DatumType'); end G= getModel(T.DesignDev,2); G= G{1}; if nargin>1 if ischar(LocalModel); L= MakeLocalModel(L,LocalModel,DatumType); else L = copymodel(L,LocalModel); end end if nargin>2 if ischar(GlobalModel); G= MakeGlobalModel(G,GlobalModel); else G = copymodel(G,GlobalModel); end end % make two-stage object TS= xregtwostage(L,G); % MakeLocalModel function L= MakeLocalModel(L,LocalModel,DatumType) if ischar(LocalModel) % make object LocalModel = feval(LocalModel); end ud= ModelClasses(L); clsval=find(strcmp(lmgroup(LocalModel),ud.Group)); if isempty(clsval) error(message('mbc:mdevtestplan:InvalidValue6')); end L = xregCreateModel(ud.fCreate{clsval},L); set(L,'DatumType',DatumType); % MakeGlobalModel function G= MakeGlobalModel(G,GlobalModel) if nargin>1 %Create the specified model and set up the base class settings from the %default model if ischar(GlobalModel) GlobalModel = str2func(GlobalModel); G = xregCreateModel(GlobalModel,G); else G = copymodel(G,GlobalModel); end end