www.gusucode.com > mbcmodels 工具箱 matlab 源码程序 > mbcmodels/@xreghybridrbf/gui_globalmodsetup.m
function [mout,ok]=gui_globalmodsetup(m,action,varargin) %GUI_GLOBALMODSETUP GUI for altering xreghybridrbf settings % % [M,OK] = GUI_GLOBALMODSETUP(M) creates a blocking GUI for choosing the % subclass of xreglinear and altering its settings. OK indicates % whether the user pressed 'OK' or 'Cancel'. % % LYT = GUI_GLOBALMODSETUP(M,'layout',FIG,P) creates a layout in figure % FIG, using the dynamic copy of a model in P. % Copyright 2000-2015 The MathWorks, Inc. and Ford Global Technologies, Inc. if nargin<2 action = 'figure'; end switch lower(action) case 'figure' [mout,ok] = gui_ModelDialog(m,'Hybrid RBF Model Settings', varargin{:}); case 'layout' mout = i_createlyt(varargin{:}); ok = 1; case 'getclasslevel' mout = mfilename('class'); case 'finalise' mout = m; otherwise error(message('mbc:xreghybridrbf:InvalidArgument2')); end function lyt = i_createlyt(figh,p) m = p.info; if ~isa(figh,'xregcontainer') ud.pointer = p; ud.figure = figh; pUD = xregGui.RunTimePointer; pUD.LinkToObject(figh); % set up the alternative algorithms ud.options = uicontrol('Parent',figh, ... 'Style','pushbutton',... 'String','Set Up...',... 'Callback', {@i_setupalg, pUD}); ud.algLabel = xregGui.labelcontrol('Parent', figh, ... 'string', sprintf('Fit algorithm: %s', getname(getFitOpt(m))), ... 'ControlSize', 65, ... 'LabelSizeMode', 'absolute', ... 'LabelSize', 150, ... 'Control', ud.options); % Create pointers to the submodels. Use runtimepointers as these will % be destroyed with the gui ud.rbfp = xregGui.RunTimePointer(m.rbfpart); ud.rbfp.LinkToObject(figh); ud.lmp = xregGui.RunTimePointer(m.linearmodpart); ud.lmp.LinkToObject(figh); tablyt = uitabgroup('Parent',figh,... 'Units','pixels'); rbfTab = mbcgui.container.uitab('Parent',tablyt,... 'LayoutBorder', [10 10 10 10], ... 'Title','Radial Basis Function Part'); linearTab = mbcgui.container.uitab('Parent',tablyt,... 'LayoutBorder', [10 10 10 10], ... 'Title','Linear Part'); ud.rbflyt = gui_globalmodsetup(m.rbfpart,'layout',rbfTab,ud.rbfp, ... 'callback', {@i_rbfmodelupdate, pUD}, ... 'training', false); rbfTab.LayoutComponent = ud.rbflyt; ud.linmodlyt = gui_globalmodsetup(m.linearmodpart,'layout',linearTab,ud.lmp, ... 'stepwise', false, ... 'callback', {@i_linmodelupdate, pUD}); linearTab.LayoutComponent = ud.linmodlyt; lyt = xreggridbaglayout(figh, ... 'dimension', [2 1], ... 'rowsizes', [25, -1], ... 'gapy', 10, ... 'elements', {ud.algLabel, tablyt}, ... 'userdata', pUD); else lyt = figh; pUD = get(lyt, 'UserData'); ud = pUD.info; m = p.info; ud.rbfp.info = m.rbfpart; ud.lmp.info = m.linearmodpart; % Update submodel layouts gui_globalmodsetup(m.rbfpart, 'layout', ud.rbflyt, ud.rbfp); gui_globalmodsetup(m.linearmodpart, 'layout', ud.linmodlyt, ud.lmp); % Update algorithm label ud.algLabel.String = sprintf('Fit algorithm: %s', getname(getFitOpt(m))); % Update with new pointer ud.pointer = p; end pUD.info = ud; function i_setupalg(~, ~, pUD) ud = pUD.info; m = ud.pointer.info; PR = xregGui.PointerRepository; ptrID = PR.stackSetPointer(ud.figure, 'watch'); [om, OK] = gui_setup(getFitOpt(m),'figure', ... {'expanded',1, 'title', 'Hybrid RBF Options','topname', 'Width selection algorithm'}, ... m); if OK m = setFitOpt(m,om); ud.algLabel.String = sprintf('Fit algorithm: %s', getname(om)); % If anything is changed in the xregoptmgr gui, then change the % fitalg to the non-linear rbffit rather than the simpler 'leastsq' m = set(m,'fitalg','hybridrbffit'); ud.pointer.info = m; end PR.stackRemovePointer(ud.figure, ptrID); function i_rbfmodelupdate(~, ~, pUD) % Update model due to changes in sub-pane ud = pUD.info; m = ud.pointer.info; m = set(m, 'rbfpart', ud.rbfp.info); m = set(m, 'fitalg', 'hybridrbffit'); ud.pointer.info = m; function i_linmodelupdate(~, ~, pUD) % Update model due to changes in sub-pane ud = pUD.info; m = ud.pointer.info; m = set(m,'linearmodpart', ud.lmp.info); % Change the status in the xreghybridrbf newlmstatus = get(get(m,'linearmodpart'),'status'); m = setstatus(m,1:length(newlmstatus),newlmstatus); % Sets the termsout to just be those with status == 2 m = IncludeAll(m); % if the xreglinear part changes, need to revert to non-linear fit m = set(m,'fitalg','hybridrbffit'); ud.pointer.info = m;