www.gusucode.com > mbcmodels 工具箱 matlab 源码程序 > mbcmodels/@xregMdlGui/@boxcox/boxcox.m
function h = boxcox(pmdev,UpdateFcn) %BOXCOX Constructor for Box-Cox transform GUI % % OBJ = BOXCOX(PMDEV) creates and displays a modal box-cox gui. % Copyright 2000-2015 The MathWorks, Inc. and Ford Global Technologies, Inc. % Class constructor h = xregMdlGui.boxcox; if nargin>1 h.UpdateFcn = UpdateFcn; end % Store the mdev pointer h.ptrMdev = pmdev; % Create the figure window in the correct place, with windows backgound color scr = get(0,'ScreenSize'); fsize= [scr(3)*0.35 scr(4)*0.6]; % create the figure h.figure = xregfigure(... 'Visible','off',... 'Tag','mvBoxCox',... 'WindowStyle','modal',... 'Name',['Box-Cox Transformation for ',pmdev.fullname],... 'CloseRequestFcn',{@i_callbacks,h,'cancel'}); % keep its handle fH = h.figure; xregcenterfigure(fH,fsize,mvf); h.InternalListeners = handle.listener(h,h.findprop('Lambda'), ... 'PropertyPostSet',{@i_LambdaChangedCallback}); % Create the GUI btMINIMISE = uicontrol('Parent',fH,... 'Style','pushbutton',... 'String','Minimize SSE',... 'Visible','off',... 'Callback',{@i_callbacks,h,'btminimise'}); btCLEAR = uicontrol('Parent',fH,... 'Style','pushbutton',... 'String','Clear Transform',... 'Visible','off',... 'Callback',{@i_callbacks,h,'btclear'}); lbLAMBDA = axestext(fH,... 'String','Current \lambda value:',... 'Visible','off'); h.editH = mbcgui.widget.Spinner('Parent',fH,... 'Visible','off',... 'Callback',{@i_callbacks,h,'edlambda'}); btOK = uicontrol('Parent',fH,... 'Style','pushbutton',... 'String','OK',... 'Visible','off',... 'Callback',{@i_callbacks,h,'ok'}); btCANCEL = uicontrol('Parent',fH,... 'Style','pushbutton',... 'String','Cancel',... 'Visible','off',... 'Callback',{@i_callbacks,h,'cancel'}); btHELP = mv_helpbutton(fH,'xreg_BoxCox'); % Create axes and graph2d axes for plotting h.AxesH = axes('Parent',fH, ... 'Units','pixels', ... 'Box','on', ... 'Visible','off', ... 'NextPlot','add', ... 'XGrid','on', ... 'YGrid','on', ... 'YScale','log'); mbcylabel(h.AxesH, 'SSE'); mbcxlabel(h.AxesH, '\lambda'); ax = mbcgui.widget.AxesPanel('AxesHandle', h.AxesH, 'Border', [40 40 10 10]); h.Graph2d = mvgraph2d(fH, 'Visible','off'); % Turn off TeX interpreter for graph2d axes set(get(h.Graph2d.axes,'YLabel'),'Interpreter','none'); set(get(h.Graph2d.axes,'XLabel'),'Interpreter','none'); set(h.Graph2d.axes,'Box','on'); set(h.Graph2d,'Grid','on'); div = xregGui.dividerline('Parent', fH, ... 'Visible', 'on'); lambdaToolbar = xreggridbaglayout(fH,... 'packstatus', 'off', ... 'dimension',[4,7],... 'colsizes', [80 5 70 20 90 7 90], ... 'rowsizes', [2 15 5 3], ... 'mergeblock', {[1 4], [5 5]}, ... 'mergeblock', {[1 4], [7 7]}, ... 'mergeblock', {[2 3], [3 3]}, ... 'elements', {[], lbLAMBDA, [], [], ... [],[],[],[], ... [], h.editH, [], [], ... [],[],[],[], ... btMINIMISE, [], [], [], ... [],[],[],[], ... btCLEAR}); pane = xreggridbaglayout(fH, ... 'border', [7 7 7 7], ... 'dimension', [5 4], ... 'rowsizes', [-1 -1 25 2 25], ... 'colsizes', [-1 65 65 65], ... 'gapy', 10, ... 'gapx', 7, ... 'mergeblock', {[1 1], [1 4]}, ... 'mergeblock', {[2 2], [1 4]}, ... 'mergeblock', {[3 3], [1 4]}, ... 'mergeblock', {[4 4], [1 4]}, ... 'elements', {h.Graph2D, ax, lambdaToolbar, div, [], ... [], [], [], [], btOK, ... [], [], [], [], btCANCEL, ... [], [], [], [], btHELP}); % set layout to be managed by xregfigure set(h.figure, 'LayoutManager', pane); set(pane,'packstatus', 'on', 'Visible','on'); % Initialise some stuff... model = h.ptrMdev.model; h.Lambda = get(model,'boxcox'); % Draw the lines h.drawLines; % update plots h.updatePlot; % add legend legend(h.AxesH, ... {'Current \lambda', 'Calculated SSE', 'Minimum SSE'... '95% Confidence Interval', 'Spline fit'}); % Keep a reference to the BC object in the userdata - this is used in Update. set(h.figure,'UserData',h,'Visible','on'); %%%%%%%%%%%% % Internal Functions %%%%%%%%%%%% % button callback dispatch function function i_callbacks(src, evt, obj, arg) doButtonCallback(obj,arg); % listener callback dispatch function i_LambdaChangedCallback(src,evt) obj = evt.AffectedObject; updatePlot(obj);