www.gusucode.com > mbcmodels 工具箱 matlab 源码程序 > mbcmodels/@xregmodel/copyToExternal.m

    function m = copyToExternal(m)
%COPYTOEXTERNAL
%
% m = copyToExternal(m);
%Use
%  m = copyToInternal(m);
%  mdls = getInternalModels(m);
%  % change internal model
%  mdls{i} = copymodel(mdls{i},NewModel{i});
%  m = setInternalModels(m,mdls);
%  m = copyToExternal(m);

%  Copyright 2007 The MathWorks, Inc. 

% get list of internal models
mdls = getInternalModels(m);

if ~isempty(mdls)
    % get inputs for each internal model
    InternalInputs = cellfun(@getInputs,mdls,'UniformOutput',false);
    % copy inputs to external input
    [m.Inputs,InternalInputs{:}] = copyToExternal(m.Inputs,InternalInputs{:});
    % update inputs for internal models
    mdls = cellfun(@setInputs,mdls,InternalInputs,'UniformOutput',false);
    % assign internal models back to main model
    m = setInternalModels(m,mdls);
end