www.gusucode.com > mbcmodels 工具箱 matlab 源码程序 > mbcmodels/@xregmulti/set.m
function varargout= set(m,prop,value) %SET overloaded set for xregmulti % % m= set(m,prop,value) % MULTIMODEL properties % 'Currentindex' : index number of 'active' model % 'Currentmodel' : model object % 'Currentweight' : weighting factor (0<w<1) % 'Weights' : vector of weights % 'Models' : cell array of models % 'ytrans' : ytransform stored in underlying models % Copyright 2000-2016 The MathWorks, Inc. and Ford Global Technologies, Inc. switch lower(prop) case 'currentindex' if value>0 && value<=length(m.weights) m.currentindex=value; end case 'currentmodel' if get(value,'nfactors')==get(m,'nfactors') stats=getSummaryStats(m); m.models{m.currentindex}=value; m= setSummaryStats(m,stats); end case 'internalcurrent' % fast set for localmulti m.models{m.currentindex}=value; case 'currentweight' m.weights(m.currentindex)=value; if sum(m.weights)>0 m.weights=m.weights./sum(m.weights); end case 'weights' value=value(:)'; if length(value)==length(m.weights) m.weights = value; sm=sum(m.weights); if sm>0 m.weights=m.weights./sm; end end case 'models' mold = m; yt= get(m,'ytrans'); stats=getSummaryStats(m); value=value(:)'; n= length(value); if n~=length(m.weights) m.weights= ones(1,n)/n; m.currentindex = 1; end m.models = value; % copy the model coding from the multimod parent to all contained models m= setSummaryStats(m,stats); m=i_copymodel(m,mold); % keep ytransform m = iSetYtrans(m,yt); case 'allmodels' % bypasses model coding copying stats=getSummaryStats(m); value=value(:)'; n= length(value); if n~=length(m.weights) m.weights= ones(1,n)/n; m.currentindex = 1; end m.models = value; m= setSummaryStats(m,stats); case 'internalmodels' % bypasses model coding copying and stats value=value(:)'; n= length(value); if n~=length(m.weights) m.weights= ones(1,n)/n; m.currentindex = 1; end m.models = value; case 'ytrans' out = getOutput(m); out.Transform = value; m = setOutput(m,out); m = iSetYtrans(m,value); case 'boxcox' out = getOutput(m); out.BoxCox = value; m = setOutput(m,out); m = iSetYtrans(m,value); otherwise try % set properties on parent - need to copy parent to each contained model? mold = m; m.xregmodel = set(m.xregmodel,prop,value); % copy the model coding from the multimod parent to all contained models m=i_copymodel(m,mold); catch % set property on current model m.models{m.currentindex}=set(m.models{m.currentindex},prop,value); end end if nargout==1 varargout{1}= m; else assignin('caller',inputname(1),m) end %-------------------------------------------------------------------------- function m=i_copymodel(m,mold) for n=1:length(m.models) yt = get(m.models{n},'ytrans'); m.models{n} = copymodel(mold,m.models{n}); % ytrans should not be copied m.models{n} = set(m.models{n},'ytrans',yt); end %-------------------------------------------------------------------------- function m = iSetYtrans(m,value) for n=1:length(m.models) % all models must have the same transform m.models{n} = set(m.models{n},'ytrans',value); end % make sure base xregmodel has no transform m.xregmodel = set(m.xregmodel,'ytrans','');