www.gusucode.com > mbctools 工具箱 matlab 源码程序 > mbctools/@mdev_local/selectModel.m
function ch= selectModel(mdev,mbH) %SELECTMODEL % Copyright 2000-2015 The MathWorks, Inc. and Ford Global Technologies, Inc. % hit compare/verify then we need to check the current rfs allow twostage % models to be reconstructed. If many, the user gets to choose which to verify. if nargin<2 mbH= MBrowser; end p= mbH.CurrentNode; ViewData= mbH.GetViewData; ms = ViewData.MessageService; ch=[]; if mle_best(mdev) && ~ms.NeedsUpdate hFig= Validate_mle('create',p,mbH.Figure); ms.registerSubFigure(hFig); else if ~isempty(p.children) pbest= p.children('bestmdev'); pbest=[pbest{:}]; if any(pbest==0) unvalmdev=p.children(pbest==0,@name); errordlg(char('You must validate all submodels ',... 'before validating this model',... 'The following sub-models have not been validated:',... unvalmdev{:}),... 'Validation Error','modal'); return end end f= find(mdev.FitOK); if ~isempty(f) % use fitted coefficients if possible to account for proper delG L= LocalModel(mdev,f(1)); else L= model(mdev); end ch= p.children; RFNames= children(mdev,'name'); [selrf,~]=SelectRF(L); if size(selrf,1)>0 if ms.NeedsUpdate % do we need to update links UpdateLinks(mdev,ms.NeedsUpdate); ms.NeedsUpdate=0; end Nf= length(get(L,'values')); if length(RFNames)>Nf RFNames(1:length(RFNames)-Nf)=[]; end %Find longest RFNames maxlen = 0; for i=1:length(RFNames) maxlen = max(maxlen,length(RFNames{i})); end % Construct formating string based o the max length formatstr = sprintf('%%-%ds ',maxlen); % construct List List=cell(size(selrf,1),1); for i=1:size(selrf,1) List{i}= sprintf(formatstr,RFNames{selrf(i,:)}); end ch= validate_local('create',p,selrf,List,mbH.Figure); ms.registerSubFigure(ch); else errordlg(['There are insufficient independent response features',... ' available to reconstruct this local model'],... 'Local Regression Error','modal'); end end