www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/@cgsurfview/@app/stats.m
function hs = stats(obj) %STATS Shows a "statistics" dialog for the first selected plot % % Displays a dialog giving statistics for the % first selected node over the variable ranges % specified in the input list. % % fig = obj.stats % % The figure is modal but non-blocking % Copyright 2000-2015 The MathWorks, Inc. and Ford Global Technologies, Inc. index=obj.hNodeSel.selection; if isempty(index) error(message('mbc:cgsurfview:app:InvalidState1')); end index=index(1); % use only first node nodeptr=obj.hNodeSel.nodes(index); svdata = obj.calculate(nodeptr); if svdata.isError hs = errordlg(svdata.getErrorMessage,'View Statistics','modal'); return end data = svdata.getValues(1); dataname = svdata.getDatasetName(1); featurename = svdata.getTitle; maxv=max(data(:)); minv=min(data(:)); meanv=mean(data(:)); stdv=std(data(:)); dPos=get(obj.fig , 'Position'); figW=250; figH=250; hs=xregfigure('Position' , [dPos(1)+100 dPos(2)+dPos(4)-100-figH figW figH] , ... 'Name' , 'Statistics', ... 'Visible', 'off', ... 'WindowStyle' , 'modal'); hClose = uicontrol('Parent' , hs , ... 'Style', 'pushbutton', ... 'Position' , [figW-75 10 65 25] , ... 'String' , 'Close' , ... 'Callback' , 'close(gcbf)'); hTitle = uicontrol('Parent' , hs , ... 'Style', 'text', ... 'String' , [ dataname ' statistics for ' featurename ':'], ... 'HorizontalAlignment', 'left'); str = {'Standard deviation' ; 'Mean' ; 'Minimum' ; 'Maximum'}; vec = [stdv; meanv; minv; maxv]; vals = arrayfun(@num2str, vec, 'UniformOutput', false); hInfo = mbcgui.table.InfoPane('Parent', hs, ... 'ListText', [str,vals], ... 'BorderType', 'beveledin'); grd = xreggridbaglayout(hs, ... 'packstatus', 'on', ... 'dimension', [3 2], ... 'rowsizes', [15 -1 25], .... 'colsizes', [-1 65], ... 'gap', 7, ... 'border', [7 7 7 7], ... 'mergeblock', {[1 1], [1 2]}, ... 'mergeblock', {[2 2], [1 2]}, ... 'elements', {hTitle, hInfo, [], [], [], hClose}); hs.LayoutManager=grd; set(grd,'packstatus','on'); hs.Visible = 'on';