www.gusucode.com > mbcmodels 工具箱 matlab 源码程序 > mbcmodels/@localmulti/updateExportModel.m
function m = updateExportModel(L,Params,X,Y) %updateExportModel update export model % m = updateExportModel(L,Params,X,Y) % % updateExportModel is a quick method for extracting the best model for % export from a localmulti. % % Inputs % L localmulti model % Params parameters stored in mdev_local.AllModels % X,Y must be sweepsets % Model % best model (xregmodel, not a localmulti!) % Copyright 2016-2016 The MathWorks, Inc. and Ford Global Technologies, Inc. if length(Params)>1 % model has parameters mdls = get(L.xregmulti,'models'); nf= nfactors(L); nmdls= length(mdls); numExtraParams= 2*nf+3+ nmdls; bestModelIndex = Params(1); numParams= Params(2); m = mdls{bestModelIndex}; if ~isfinite(numParams) % new parameters (post-15b) with all fits st = numExtraParams+3; ExtraParams = Params(3:numExtraParams+2); Rng= reshape(ExtraParams(1:2*nf),nf,2); for i=1:bestModelIndex % iterate through models to find best model parameters numParams= Params(st); if isnan(numParams) % model not fitted st = st+1; else mparams= Params(st+1:st+numParams); st = st+numParams+1; end end else % old model parameter format (pre-15b) with just best fit mparams = Params(3:2+numParams); if length(Params)>=numParams+2+numExtraParams % Range stored in parameters ExtraParams= Params( (numParams+3): (numParams+2+numExtraParams)); Rng= reshape(ExtraParams(1:2*nf),nf,2); else % get range from model Rng = getcode(L); end end if ~all(Rng(:)==0) % set coding range m = setcode(m,Rng); end m= updateallparameters( m,mparams); if nargin>2 % pevinit - requires sweepsets [X,Y]= checkdata(m,X,Y); m = InitModel(m,X,Y,[],1); end else % just return the current model m = get(L.xregmulti,'currentmodel'); Rng = getcode(L); m = setcode(m,Rng); end