www.gusucode.com > mbcexpr 工具箱 matlab 源码程序 > mbcexpr/+cgsimfill/@EvalPoints/CreateModel.m
function pMod= CreateModel(V, CGP, names, pExpressions) %CREATEMODEL create a model with links % % pMod= CreateModel(F, CGP, NAMES, PEXRESSIONS) % Copyright 2005-2008 The MathWorks, Inc. if ~iscell( names ) % make sure we have a name for each model. names = repmat( {names}, size( pExpressions ) ); end for i=length(pExpressions) pExpr= pExpressions(i); % make feature model for this expressions pModNode = cgExpr2Model(pExpr, CGP, names{i}, false ); % get the cgmodexpr from the node pMod= pModNode.getdata; % get the list of model inputs pModelInputs = pMod.getinputs(); % get the link information [pVar, pLink] = V.getLinks(); % find the linked inputs to the model [indModelInputs, indLinks] = ismember( pModelInputs, pVar ); % replace each linked input with a model of the link input. for n = find(indModelInputs) thisLink = pLink(indLinks(n)); if ~thisLink.isa( 'cgmodexpr' ) pNewModNode = cgExpr2Model(thisLink, CGP,[thisLink.getname,'_Model'],false ); thisLink = pNewModNode.getdata(); end if ~ismember(pModelInputs(n),thisLink.getinports) % Update model input with the link ptr/model pModelInputs(n) = thisLink; else warning(message('mbc:cgsimfill:CreateModel:InvalidLink', thisLink.getname, pModelInputs( n ).getname, pMod.getname)) end end % update the models inputs pMod.info = setinputs( pMod.info, pModelInputs); end