www.gusucode.com > mbcmodels 工具箱 matlab 源码程序 > mbcmodels/@xregcubic/ModelBuildGUI.m
function [minK,maxK,om,ok] = ModelBuildGUI(m, numobs) %MODELBUILDGUI GUI for building models from templates % % [mink,maxk,om,ok] = MODELBUILDGUI(M, NUMOBS) displays a dialog that % returns values for the min and max order for polynomial models and an % optimisation manager for the stepwise. % Copyright 2000-2015 The MathWorks, Inc. and Ford Global Technologies, Inc. str = ['A model will be created for each order value between the minimum and ', ... 'maximum values specified below. A model of order ''k'' will include ', ... 'all terms, including cross terms, with a total order less than or ', ... 'equal to ''k''. ',... sprintf('\n\n'),... 'The stepwise setting will be applied to all the models created.']; dlg = mbcgui.container.Dialog('Name','Model Building Options',... 'InfoString',str,... 'InfoHeight',75,... 'Size',[450 260],... 'Buttons','OK_CANCEL',... 'Resize','off'); fH = dlg.Figure; % using the numobs, find the highest order poly we can build mtest = m; nf = nfactors(m); for i = 1:20 set(mtest,'order',i*ones(1,nf)); set(mtest,'maxinteract',i); max_order = i-1; if numParams(mtest)>numobs break end end minedit = mbcgui.widget.Spinner('Parent', fH, ... 'Min',1,'Max',max_order, ... 'Value',1, ... 'Rule','int'); maxedit = mbcgui.widget.Spinner('Parent', fH, ... 'Min',1,'Max',max_order, ... 'Value',max_order, ... 'Rule','int'); FitOptions = uicontrol('Parent',fH,... 'Style','popupmenu',... 'String',{'None','Minimize PRESS','Forward Selection','Backward Selection'}); minctrl = xregGui.labelcontrol('parent',fH,... 'String', 'Minimum order of polynomial:',... 'ControlSize', 60, ... 'LabelSizeMode', 'absolute', ... 'LabelSize', 150, ... 'Control', minedit); maxctrl = xregGui.labelcontrol('parent',fH,... 'String', 'Maximum order of polynomial:',... 'ControlSize', 60, ... 'LabelSizeMode', 'absolute', ... 'LabelSize', 150, ... 'Control', maxedit); stepctrl = xregGui.labelcontrol('parent',fH,... 'String', 'Stepwise:',... 'ControlSize', 120, ... 'LabelSizeMode', 'absolute', ... 'LabelSize', 150, ... 'Control', FitOptions); ctrlGrid = xreggridbaglayout(fH, ... 'Packstatus', 'off', ... 'Dimension', [3 1], ... 'Gapy', 5, ... 'RowSizes', [20 20 20], ... 'elements', {minctrl, maxctrl, stepctrl}); dlg.Content = ctrlGrid; closeMode = dlg.showDialog(); if strcmp(closeMode, 'OK') minK = minedit.Value; maxK = maxedit.Value; if maxK<minK maxK = minK; end % sort out stepwise om = i_stepwise(m,FitOptions); ok = 1; else minK = []; maxK = []; om = []; ok = 0; end delete(fH); %---------------------------------------------------- % function i_stepwise %---------------------------------------------------- function om = i_stepwise(m, hnd) opt= get(hnd,'Value'); switch opt case 1 om = 'leastsq'; case 2 om = minpress(m); case 3 om = forwardselect(m); case 4 om = backwardselect(m); end