www.gusucode.com > mbcmodels 工具箱 matlab 源码程序 > mbcmodels/@xregcubic/xregcubic.m
function mvp= xregcubic(order,labels) %XREGCUBIC Multivariate cubic model object constructor % % M = XREGCUBIC(ORDER, LABELS) where ORDER is the order of each factor and % LABELS is a cell array containing the desired term labels. % % M = XREGCUBIC(SWEEPSET) creates an xregcubic model based on the given % sweepset. % Copyright 2000-2007 The MathWorks, Inc. and Ford Global Technologies, Inc. if nargin<1 order=[3 3 3 3]; end if isa(order,'sweepset') % Takes a guess at initial base model given a sweepset to work on. % This is assumed to be an xregcubic of order [3 3 3 2] if there are enough % independents defined. XNames= get(order,'Name'); if size(order,2) >= 4 order= [3 3 3 2 zeros(1,size(order,2)-4)]; else order= 3*ones(1,size(order,2)); end % Now recursively call xregcubic mvp = xregcubic(order,XNames); X=double(order); % Defaults are for the min and max coding to be defined by the data Range = [min(X);max(X)]'; mvp = setcode(mvp,Range); return end NewSettings= 0; if isstruct(order); % Old structure from xreg3xspline/LOADOBJ [mvp,mlin]= i_Update(order); elseif ischar(order) if strcmp(order,'nfactors') order=repmat(3,1,labels); mvp=xregcubic(order); return end else if nargin<2 Inputs = mbcinputfactor(length(order)); else if ~isa(labels,'cell') labels=cellstr(labels); end if length(order)~=length(labels) error(message('mbc:xregcubic:InvalidArgument1')) end Inputs = mbcinputfactor('Name',labels,'Symbol',labels); end order=order(:)'; mvp.reorder= []; mvp.N = []; % construct xreglinear (coeffs set to 1:len) mlin = xregCreateModel(@xreglinear,Inputs); % xregcubic Version Number mvp.version = 3; mvp.MaxInteract= max(order); NewSettings= 1; end % xregcubic Version Number mvp.version = 3; mvp= class(mvp,'xregcubic',mlin); if NewSettings mvp= termCount(mvp,order,mvp.MaxInteract); end mvp= setstatus(mvp,1,1); % update old class structure function [mvp,mlin]= i_Update(mvp) mlin=xreglinear(mvp.xreglinear); if mvp.version < 2 % Set up parent xreglinear [s,i] = sort(mvp.reorder); labels= mvp.labels(i); xi= xinfo(mlin); if isempty(xi) % dependent factor info xi= struct('Names',{labels},... 'Units','',... 'Symbols',{labels}); else xi.Names= labels; xi.Symbols= labels; end mlin= xinfo(mlin,xi); mvp=mv_rmfield(mvp,'labels'); end if mvp.version < 3 % add MaxInteract property MaxInteract = find(mvp.N,1,'last'); if isempty(MaxInteract) MaxInteract = 0; end mvp.MaxInteract= MaxInteract; end mvp=mv_rmfield(mvp,'xreglinear');