utstats.m
上传用户:haiyisale
上传日期:2013-01-09
资源大小:3246k
文件大小:11k
源码类别:

波变换

开发平台:

Matlab

  1. function varargout = utstats(option,fig,varargin)
  2. %UTSTATS Utilities for statistics tools.
  3. %   VARARGOUT = UTSTATS(OPTION,FIG,VARARGIN)
  4. %   M. Misiti, Y. Misiti, G. Oppenheim, J.M. Poggi 04-May-98.
  5. %   Last Revision: 04-May-1999.
  6. %   Copyright 1995-2002 The MathWorks, Inc.
  7. %   $Revision: 1.4 $  $Date: 2002/04/14 19:48:47 $
  8. % Tag property of objects.
  9. %-------------------------
  10. tag_sta_val = 'Fra_StaVal';
  11. switch option
  12.     case 'create'
  13.         % Get Globals.
  14.         %--------------
  15.         [Def_Txt_Height,Def_Btn_Height,X_Spacing,Y_Spacing, ...
  16.          Def_TxtBkColor,Def_FraBkColor] = ...
  17.             mextglob('get',...
  18.                 'Def_Txt_Height','Def_Btn_Height','X_Spacing','Y_Spacing', ...
  19.                 'Def_TxtBkColor','Def_FraBkColor'  ...
  20.                 );
  21.         % General graphical parameters initialization.
  22.         %--------------------------------------------
  23.         % Borders and double borders.
  24.         dx = X_Spacing;  dx2 = 2*dx;
  25.         dy = Y_Spacing;  dy2 = 2*dy;
  26.         % Defaults.
  27.         %----------
  28.         xleft = Inf; xright  = Inf; xloc = Inf;
  29.         ytop  = Inf; ybottom = Inf; yloc = Inf;
  30.         bkColor = Def_FraBkColor;
  31.         % Inputs.
  32.         %--------
  33.         nbarg = length(varargin);
  34.         for k=1:2:nbarg
  35.             arg = lower(varargin{k});
  36.             switch arg
  37.               case 'left'    , xleft   = varargin{k+1};
  38.               case 'right'   , xright  = varargin{k+1};
  39.               case 'xloc'    , xloc    = varargin{k+1};
  40.               case 'bottom'  , ybottom = varargin{k+1};
  41.               case 'top'     , ytop    = varargin{k+1};
  42.               case 'yloc'    , yloc    = varargin{k+1};
  43.               case 'bkcolor' , bkColor = varargin{k+1};              
  44.             end 
  45.         end  
  46.         old_units  = get(fig,'units');
  47.         fig_units  = 'pixels';
  48.         if ~isequal(old_units,fig_units), set(fig,'units',fig_units); end
  49.         % Setting frame position.
  50.         %------------------------
  51.         [dummy,win_width ,dummy,cmd_width] = wfigmngr('figsizes',fig);
  52.         w_fra   = win_width-cmd_width-2*dx2;
  53.         h_fra   = 3*Def_Btn_Height+8*dy;
  54.         xleft   = utposfra(xleft,xright,xloc,w_fra);
  55.         ybottom = utposfra(ybottom,ytop,yloc,h_fra);
  56.         pos_fra = [xleft,ybottom,w_fra,h_fra];
  57.         % Position property of objects.
  58.         %------------------------------
  59.         yd_ini  = pos_fra(2)+h_fra-Def_Btn_Height-dy2;
  60.         wx      = (pos_fra(3)-4*dx)/8;
  61.         xl            = pos_fra(1)+dx;
  62.         yd            = yd_ini;
  63.         pos_mean_txt  = [xl, yd, 4*wx/5, Def_Btn_Height];
  64.         yd            = yd-Def_Btn_Height-dy2;
  65.         pos_med_txt   = [xl, yd, 4*wx/5, Def_Btn_Height];
  66.         yd            = yd-Def_Btn_Height-dy2;
  67.         pos_mode_txt  = [xl, yd, 4*wx/5, Def_Btn_Height];
  68.         xl            = pos_mean_txt(1)+pos_mean_txt(3)+dx+6*wx/5;
  69.         yd            = yd_ini;
  70.         pos_max_txt   = [xl, yd, wx, Def_Btn_Height];
  71.         yd            = yd-Def_Btn_Height-dy2;
  72.         pos_min_txt   = [xl, yd, wx, Def_Btn_Height];
  73.         yd            = yd-Def_Btn_Height-dy2;
  74.         pos_range_txt = [xl, yd, wx, Def_Btn_Height];
  75.         xl            = pos_max_txt(1)+pos_max_txt(3)+dx+6*wx/5;
  76.         yd            = yd_ini;
  77.         pos_std_txt   = [xl, yd, 13*wx/5, Def_Btn_Height];
  78.         yd            = yd-Def_Btn_Height-dy2;
  79.         pos_mad_txt   = [xl, yd, 13*wx/5, Def_Btn_Height];
  80.         yd            = yd-Def_Btn_Height-dy2;
  81.         pos_madm_txt  = [xl, yd, 13*wx/5, Def_Btn_Height];
  82.         pos_mean_val  = [ pos_mean_txt(1)+pos_mean_txt(3)   ,...
  83.                           pos_mean_txt(2)                   ,...
  84.                           6*wx/5                            ,...
  85.                           Def_Btn_Height                    ];
  86.         pos_med_val   = [ pos_med_txt(1)+pos_med_txt(3)     ,...
  87.                           pos_med_txt(2)                    ,...
  88.                           6*wx/5                            ,...
  89.                           Def_Btn_Height                    ];
  90.         pos_mode_val  = [ pos_mode_txt(1)+pos_mode_txt(3)   ,...
  91.                           pos_mode_txt(2)                   ,...
  92.                           6*wx/5                            ,...
  93.                           Def_Btn_Height                    ];
  94.         pos_max_val   = [ pos_max_txt(1)+pos_max_txt(3)     ,...
  95.                           pos_max_txt(2)                    ,...
  96.                           6*wx/5                            ,...
  97.                           Def_Btn_Height                    ];
  98.         pos_min_val   = [ pos_min_txt(1)+pos_min_txt(3)     ,...
  99.                           pos_min_txt(2)                    ,...
  100.                           6*wx/5                            ,...
  101.                           Def_Btn_Height                    ];
  102.         pos_range_val = [ pos_range_txt(1)+pos_range_txt(3) ,...
  103.                           pos_range_txt(2)                  ,...
  104.                           6*wx/5                            ,...
  105.                           Def_Btn_Height                    ];
  106.         pos_std_val   = [ pos_std_txt(1)+pos_std_txt(3)     ,...
  107.                           pos_std_txt(2)                    ,...
  108.                           6*wx/5                            ,...
  109.                           Def_Btn_Height                    ];
  110.         pos_mad_val   = [ pos_mad_txt(1)+pos_mad_txt(3)     ,...
  111.                           pos_mad_txt(2)                    ,...
  112.                           6*wx/5                            ,...
  113.                           Def_Btn_Height                    ];
  114.         pos_madm_val  = [ pos_madm_txt(1)+pos_madm_txt(3)   ,...
  115.                           pos_madm_txt(2)                   ,...
  116.                           6*wx/5                            ,...
  117.                           Def_Btn_Height                    ];
  118.         % String property of objects.
  119.         %----------------------------
  120.         str_mean_txt  = 'Mean';
  121.         str_med_txt   = 'Median';
  122.         str_mode_txt  = 'Mode';
  123.         str_max_txt   = 'Maximum';
  124.         str_min_txt   = 'Minimum';
  125.         str_range_txt = 'Range';
  126.         str_std_txt   = 'Standard deviation';
  127.         str_mad_txt   = 'Median absolute deviation';
  128.         str_madm_txt  = 'Mean absolute deviation';
  129.         % Frame Stats construction.
  130.         %--------------------------
  131.         txt_color = Def_FraBkColor;
  132.         val_color = Def_TxtBkColor;
  133.         fra_utl = uicontrol('Parent',fig,...
  134.                             'Style','frame',...
  135.                             'Unit',fig_units,...
  136.                             'Position',pos_fra,...
  137.                             'Visible','off',...
  138.                             'Backgroundcolor',txt_color,...
  139.                             'Foregroundcolor','k',...
  140.                             'tag',tag_sta_val ...
  141.                             );
  142.         commonPropTxt = {...
  143.              'Parent',fig,...
  144.              'Style','Text',...
  145.              'Unit',fig_units,...
  146.              'HorizontalAlignment','left',...
  147.              'Visible','off',...
  148.              'Backgroundcolor',txt_color...
  149.              };
  150.         commonPropVal = {...
  151.              'Parent',fig,...
  152.              'Style','Text',...
  153.              'Unit',fig_units,...
  154.              'HorizontalAlignment','center',...
  155.              'Visible','off',...
  156.              'Backgroundcolor',val_color...
  157.              };
  158.         txt_mean_txt  = uicontrol(commonPropTxt{:}, ...
  159.                             'Position',pos_mean_txt,'String',str_mean_txt);
  160.         txt_mean_val  = uicontrol(commonPropVal{:},'Position',pos_mean_val);
  161.         txt_med_txt   = uicontrol(commonPropTxt{:}, ...
  162.                             'Position',pos_med_txt,'String',str_med_txt);
  163.         txt_med_val   = uicontrol(commonPropVal{:},'Position',pos_med_val);
  164.         txt_mode_txt  = uicontrol(commonPropTxt{:}, ...
  165.                             'Position',pos_mode_txt,'String',str_mode_txt);
  166.         txt_mode_val  = uicontrol(commonPropVal{:},'Position',pos_mode_val);
  167.         txt_max_txt   = uicontrol(commonPropTxt{:}, ...
  168.                             'Position',pos_max_txt,'String',str_max_txt);
  169.         txt_max_val   = uicontrol(commonPropVal{:},'Position',pos_max_val);
  170.         txt_min_txt   = uicontrol(commonPropTxt{:}, ...
  171.                             'Position',pos_min_txt,'String',str_min_txt);
  172.         txt_min_val   = uicontrol(commonPropVal{:},'Position',pos_min_val);
  173.         txt_range_txt = uicontrol(commonPropTxt{:}, ...
  174.                             'Position',pos_range_txt,'String',str_range_txt);
  175.         txt_range_val = uicontrol(commonPropVal{:},'Position',pos_range_val);
  176.         txt_std_txt   = uicontrol(commonPropTxt{:}, ...
  177.                             'Position',pos_std_txt,'String',str_std_txt);
  178.         txt_std_val   = uicontrol(commonPropVal{:},'Position',pos_std_val);
  179.         txt_mad_txt   = uicontrol(commonPropTxt{:}, ...
  180.                             'Position',pos_mad_txt,'String',str_mad_txt);
  181.         txt_mad_val   = uicontrol(commonPropVal{:},'Position',pos_mad_val);
  182.         txt_madm_txt  = uicontrol(commonPropTxt{:}, ...
  183.                             'Position',pos_madm_txt,'String',str_madm_txt);
  184.         txt_madm_val  = uicontrol(commonPropVal{:},'Position',pos_madm_val);
  185.         drawnow
  186.         % Sets of handles.
  187.         %-----------------
  188.         ud.handles = [...
  189.                        fra_utl; ...
  190.                        txt_mean_txt; txt_med_txt; txt_mode_txt;  ...
  191.                        txt_max_txt ; txt_min_txt; txt_range_txt; ...
  192.                        txt_std_txt ; txt_mad_txt; txt_madm_txt;  ...
  193.                        txt_mean_val; txt_med_val; txt_mode_val;  ...
  194.                        txt_max_val;  txt_min_val; txt_range_val; ...
  195.                        txt_std_val;  txt_mad_val; txt_madm_val   ...
  196.                        ];
  197.         set(fra_utl,'Userdata',ud);
  198.         if nargout>0
  199.             varargout{1} = ud.handles;               
  200.             varargout{2} = h_fra;
  201.         end
  202.     case 'display'
  203.         val_handles = utstats('handles',fig,'val');
  204.         tab_values  = varargin{1};
  205.         for k=1:length(val_handles)
  206.             set(val_handles(k),'string',sprintf('%1.4g',tab_values(k)));
  207.         end
  208.     case 'handles'
  209.         fra = findobj(fig,'Style','frame','tag',tag_sta_val);
  210.         ud  = get(fra,'Userdata');
  211.         varargout{1} = ud.handles;
  212.         if length(varargin)>0
  213.            type = varargin{1};
  214.            switch type
  215.              case 'all' ,
  216.              case 'val' , varargout{1}([1:10]) = [];
  217.              case 'txt' , varargout{1}([1,11:end]) = [];
  218.            end
  219.         end 
  220.     otherwise
  221.         errargt(mfilename,'Unknown Option','msg');
  222.         error('*');
  223. end