www.gusucode.com > mbcmodels 工具箱 matlab 源码程序 > mbcmodels/@xregtwostage/copyToInternal.m
function TS= copyToInternal(TS) %COPYTOINTERNAL % Copyright 2007 The MathWorks, Inc. % twostage info Inputs = getInputs(TS.xregmodel); nl= nfactors(TS.Local); % extract base local model LocalInputs = Inputs(1:nl); % copy to internal local model % input and output (no transform) LocalInputs = copyToInternal(LocalInputs,getInputs(TS.Local)); TS.Local = setInputs(TS.Local,LocalInputs,true); if ~isempty(TS.Global) % get models from two-stage HasDatum = isa(TS.datum,'xregmodel'); mdls = TS.Global; ng = length(mdls); if HasDatum mdls = [mdls(:)',{TS.datum}]; end if ~isempty(mdls); InternalInputs = cellfun(@getInputs,mdls,'UniformOutput',false); % copy to internal global models GlobalInputs = Inputs(nl+1:end); % only copy input info [InternalInputs{:}] = copyToInternal(GlobalInputs,InternalInputs{:}); % set inputs back in models - make sure targets are updated mdls = cellfun(@(m,Inputs) setInputs(m,Inputs,true),mdls,InternalInputs,'UniformOutput',false); % assign models back to two-stage TS.Global = mdls(1:ng); if HasDatum TS.datum = mdls{end}; end end end