www.gusucode.com > mbctools 工具箱 matlab 源码程序 > mbctools/@mdevproject/multimodel.m
function [Maps,OpPoints,ModePoints] = multimodel(MP,pTPs) %MULTIMODEL make composite or point-by-point for project % % [Maps,OpPoints,ModePoints] = multimodel(MP,pTPs) % Copyright 2006-2011 The MathWorks, Inc. if nargin<2 % default is to use all testplans pTPs = children(MP); end NumStages = pveceval(pTPs,@numstages); if ~all([NumStages{:}]==2) error(message('mbc:mdevproject:InvalidValue')) end % check global if length(pTPs)>1 globalsyms= get( pTPs(1).model, 'symbol'); OK = pveceval(pTPs(2:end),@(T) isequal(get( model(T), 'symbol'),globalsyms)); if ~all([OK{:}]) error(message('mbc:mdevproject:InvalidValue1')) end end % make multimodels and boundary models for each testplan [LocalMaps,BdryModels] = pveceval(pTPs,@multimodel); Vars = pveceval(pTPs,@children,@varname); for i=2:length(Vars) if ~isequal(Vars{1},Vars{i}) [OK,loc] = ismember(Vars{i},Vars{1}); if all(OK) && length(Vars{i})==length(Vars{i}) % reorder responses LocalMaps{i} = LocalMaps{i}(loc); else error(message('mbc:mdevproject:InvalidValue2', pTPs( i ).name)) end end end LocalMaps = cat(1,LocalMaps{:}); numResps = size(LocalMaps,2); Maps = cell(1,numResps); OpPoints=[]; ModePoints=[]; for i=1:numResps % merge response models if length(pTPs)>1 m = cgCompositeModel.create(LocalMaps(:,i),[name(MP),'_Mode']); OpPoints = OpPointDataset(m); ModePoints = ModeDataset(m); else m = LocalMaps{i}; OpPoints = getSwitchPoints(m); ModePoints = []; end if i==1 if length(BdryModels)>1 && all(cellfun(@(con) isa(con,'conswitch'),BdryModels)) % merge boundary models c = merge(BdryModels{:},[name(MP),'_Mode']); elseif length(BdryModels)>1 && all(cellfun(@(con) isa(con,'boundaryModelWrapper'),BdryModels)) % merge boundary models c = merge(BdryModels{:},m); elseif length(BdryModels)==1 c = BdryModels{1}; else c = []; end end % make into a statsmodel INFO = exportinfo( MP ,address(MP), {m}); Maps{i} = setinfo(m,INFO); Maps{i} = setconstraints(m,c); end