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

    function mdl = xregCreateModel(fModel,InputInfo,varargin)
%XREGCREATEMODEL factory function for creating models
%
% mdl = xregCreateModel(fModel,InputInfo)
%   fModel function handle to constructor 
%   InputInfo : number of factors
%               cell array of input information (nf x 5)
%                  {Symbol,Min,Max,Transform,Name}
%               mbcinputfactor array
%               xregmodel - does copymodel
%   Optional property/value pairs

%   Copyright 2007 The MathWorks, Inc. 

if nargin==0
    fModel = @xregcubic;
end

if nargin<2
    InputInfo = 1;
end
Inputs = mbcinputfactor(InputInfo);
nf = length(Inputs);

% Create model
mdl = fModel('nfactors',nf);
% this makes sure target is set correctly for model inputs
mdl = setupTargets(mdl);

if isa(InputInfo,'xregmodel')
    % copy information from another model
    mdl = copymodel(InputInfo,mdl);
else
    mdl = setInputs(mdl,Inputs);
end

% set additional properties
for i=1:2:length(varargin)
    mdl = set(mdl,varargin{i},varargin{i+1});
end