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

波变换

开发平台:

Matlab

  1. function dw1dutil(option,win_dw1dtool,in3,in4)
  2. %DW1DUTIL Discrete wavelet 1-D utilities.
  3. %   DW1DUTIL(OPTION,WIN_DW1DTOOL,IN3,IN4)
  4. %   M. Misiti, Y. Misiti, G. Oppenheim, J.M. Poggi 12-Mar-96.
  5. %   Last Revision: 03-Feb-2003.
  6. %   Copyright 1995-2004 The MathWorks, Inc.
  7. %   $Revision: 1.15.4.2 $ $Date: 2004/03/15 22:40:17 $
  8. % Default values.
  9. %----------------
  10. max_lev_anal = 12;
  11. % MemBloc1 of stored values.
  12. %---------------------------
  13. n_param_anal   = 'DWAn1d_Par_Anal';
  14. ind_sig_name   = 1;
  15. ind_sig_size   = 2;
  16. ind_wav_name   = 3;
  17. ind_lev_anal   = 4;
  18. ind_axe_ref    = 5;
  19. ind_act_option = 6;
  20. ind_ssig_type  = 7;
  21. ind_thr_val    = 8;
  22. nb1_stored     = 8;
  23. % Tag property of objects.
  24. %-------------------------
  25. tag_m_savesyn   = 'Save_Syn';
  26. tag_m_savecfs   = 'Save_Cfs';
  27. tag_m_savedec   = 'Save_Dec';
  28. tag_cmd_frame   = 'Cmd_Frame';
  29. tag_pus_anal    = 'Pus_Anal';
  30. tag_pus_deno    = 'Pus_Deno';
  31. tag_pus_comp    = 'Pus_Comp';
  32. tag_pus_hist    = 'Pus_Hist';
  33. tag_pus_stat    = 'Pus_Stat';
  34. tag_pop_viewm   = 'View_Mode';
  35. tag_pus_dispopt = 'Pus_Options';
  36. tag_valapp_scr  = 'ValApp_Scr';
  37. tag_txtapp_scr  = 'TxtApp_Scr';
  38. tag_valdet_scr  = 'ValDet_Scr';
  39. tag_txtdet_scr  = 'TxtDet_Scr';
  40. tag_declev      = 'Pop_DecLev';
  41. tag_txtdeclev   = 'Txt_DecLev';
  42. % Handles of tagged objects.
  43. %---------------------------
  44. children    = get(win_dw1dtool,'Children');
  45. axe_handles = findobj(children,'flat','type','axes');
  46. switch option
  47.     case {'clean','enable','set_gui'}
  48.         % Handles of tagged objects.
  49.         %---------------------------
  50.         m_files     = wfigmngr('getmenus',win_dw1dtool,'file');
  51.         m_savesyn   = findobj(m_files,'Tag',tag_m_savesyn);
  52.         m_savecfs   = findobj(m_files,'Tag',tag_m_savecfs);
  53.         m_savedec   = findobj(m_files,'Tag',tag_m_savedec);
  54.         uic_handles = findobj(children,'flat','type','uicontrol');
  55.         pop_handles = findobj(uic_handles,'Style','popupmenu');
  56.         pus_handles = findobj(uic_handles,'Style','pushbutton');
  57.         txt_handles = findobj(uic_handles,'Style','text');
  58.         pus_dispopt = findobj(uic_handles,'tag',tag_pus_dispopt);
  59.         pus_anal    = findobj(pus_handles,'Tag',tag_pus_anal);
  60.         pus_deno    = findobj(pus_handles,'Tag',tag_pus_deno);
  61.         pus_comp    = findobj(pus_handles,'Tag',tag_pus_comp);
  62.         pus_hist    = findobj(pus_handles,'Tag',tag_pus_hist);
  63.         pus_stat    = findobj(pus_handles,'Tag',tag_pus_stat);
  64.         pop_viewm   = findobj(pop_handles,'tag',tag_pop_viewm);
  65.         pop_app_scr = findobj(pop_handles,'Tag',tag_valapp_scr);
  66.         pop_det_scr = findobj(pop_handles,'Tag',tag_valdet_scr);
  67.         pop_lev_dec = findobj(pop_handles,'Tag',tag_declev);
  68.         txt_app_scr = findobj(txt_handles,'Tag',tag_txtapp_scr);
  69.         txt_det_scr = findobj(txt_handles,'Tag',tag_txtdet_scr);
  70.         txt_lev_dec = findobj(txt_handles,'Tag',tag_txtdeclev);
  71. end
  72. switch option
  73.     case 'set_par'
  74.         % Reading Analysis Parameters.
  75.         %----------------------------
  76.         [Wave_Name,Level_Anal] = cbanapar('get',win_dw1dtool,'wav','lev');
  77.         % Setting Analysis parameters
  78.         %-----------------------------
  79.         wmemtool('wmb',win_dw1dtool,n_param_anal, ...
  80.                        ind_wav_name,Wave_Name, ...
  81.                        ind_lev_anal,Level_Anal ...
  82.                        );
  83.     case 'clean'
  84.         % in3 = type of loading.
  85.         %-----------------------
  86.         % 'load_sig' , 'load_dec'
  87.         % 'load_cfs' , 'demo'    
  88.         %-----------------------
  89.         if nargin<4 , in4 = ''; end
  90.         switch in3
  91.             case {'load_cfs','synt'}
  92.                 str_btn = 'Synthesize';
  93.                 cba_btn = ['dw1dmngr(''synt'',' int2str(win_dw1dtool) ');'];
  94.             otherwise        
  95.                 str_btn = 'Analyze';
  96.                 cba_btn = ['dw1dmngr(''anal'',' int2str(win_dw1dtool) ');'];
  97.         end
  98.         set(pus_anal,'String',xlate(str_btn),'Callback',cba_btn);
  99.         % Writing Synthesized Signal Type.
  100.         %----------------------------------
  101.         wmemtool('wmb',win_dw1dtool,n_param_anal,ind_ssig_type,'ss');
  102.         % Cleaning files.
  103.         %----------------
  104.         dw1dfile('del',win_dw1dtool);
  105.         % Testing first use.
  106.         %-------------------
  107.         active_option = wmemtool('rmb',win_dw1dtool,n_param_anal, ...
  108.                                        ind_act_option);
  109.         if isempty(active_option) , first = 1; else, first = 0; end
  110.         % End of Cleaning when first is true.
  111.         %------------------------------------
  112.         if first , return; end
  113.         cba_disp = ['dw1ddisp(''create'',' int2str(win_dw1dtool) ');'];
  114.         set(pus_dispopt,...
  115.                         'Style','pushbutton',            ...
  116.                         'String',xlate('More Display Options'), ...
  117.                         'Callback',cba_disp);
  118.         % Setting enable property of objects.
  119.         %------------------------------------
  120.         set([ m_savesyn, m_savecfs,  m_savedec],'Enable','Off');
  121.         cbanapar('enable',win_dw1dtool,'off');
  122.         set([ pus_anal,    pus_deno,                ...
  123.               pus_comp,    pus_hist,    pus_stat,   ...
  124.               pop_viewm,   pus_dispopt,             ...
  125.               pop_lev_dec, pop_app_scr, pop_det_scr ...
  126.               ],...
  127.               'Enable','off'...
  128.               );
  129.         cbcolmap('enable',win_dw1dtool,'off')
  130.         % Cleaning DynVTool.
  131.         %-------------------
  132.         dynvtool('stop',win_dw1dtool);
  133.         % Cleaning GUI.
  134.         %--------------
  135.         dw1dvmod('ch_vm',win_dw1dtool,1);
  136.         switch in4
  137.             case {'new_anal','new_synt'}
  138.                 set([pop_lev_dec,pop_app_scr,pop_det_scr],'Value',1);
  139.             otherwise
  140.                 str_lev_data = int2str([1:max_lev_anal]');
  141.                 cbanapar('set',win_dw1dtool,...
  142.                     'nam','',             ...
  143.                     'wav','haar',         ...
  144.                     'lev',{'String',str_lev_data,'Value',1})
  145.                 set([pop_lev_dec,pop_app_scr,pop_det_scr], ...
  146.                             'String',str_lev_data,'Value',1);
  147.         end
  148.     case 'set_gui'
  149.         % in3 = calling option.
  150.         % in4  : optional (new_anal or new_synt).
  151.         %-----------------------------------------
  152.         if nargin<4 , in4 = ''; end
  153.         switch in3
  154.             case 'load_sig'
  155.                 [Sig_Name,Sig_Size] = ...
  156.                         wmemtool('rmb',win_dw1dtool,n_param_anal,...
  157.                                        ind_sig_name,ind_sig_size);
  158.                 Sig_Size = max(Sig_Size);
  159.                 levm     = wmaxlev(Sig_Size,'haar');
  160.                 levmax   = min(levm,max_lev_anal);
  161.                 if isempty(in4)
  162.                     lev = min(levmax,5);
  163.                     str_lev_data = int2str([1:levmax]');
  164.                     cbanapar('set',win_dw1dtool,...
  165.                              'n_s',{Sig_Name,Sig_Size},    ...
  166.                              'lev',{'String',str_lev_data,'Value',lev});
  167.                     set([pop_lev_dec,pop_app_scr,pop_det_scr], ...
  168.                                 'String',str_lev_data);
  169.                 end
  170.             case {'demo','load_dec'}
  171.                 [Sig_Name,Sig_Size,Wave_Name,Level_Anal] =    ...
  172.                         wmemtool('rmb',win_dw1dtool,n_param_anal,  ...
  173.                                        ind_sig_name,ind_sig_size, ...
  174.                                        ind_wav_name,ind_lev_anal);
  175.                 Sig_Size = max(Sig_Size);
  176.                 levm     = wmaxlev(Sig_Size,'haar');
  177.                 if levm<Level_Anal , levm = Level_Anal; end
  178.                 levmax = min(levm,max_lev_anal);
  179.                 str_lev_data = int2str([1:levmax]');
  180.                 cbanapar('set',win_dw1dtool,...
  181.                     'n_s',{Sig_Name,Sig_Size},...
  182.                     'wav',Wave_Name,      ...
  183.                     'lev',{'String',str_lev_data,'Value',Level_Anal});
  184.                 levels = int2str([1:Level_Anal]');
  185.                 set(pop_lev_dec,'String',levels,'Value',Level_Anal);
  186.                 set([pop_app_scr,pop_det_scr],'String',levels,'Value',1);
  187.                 dw1dvmod('ini_vm',win_dw1dtool);
  188.             case 'load_cfs'
  189.                 [Sig_Name,Sig_Size,Wave_Name,Level_Anal] =    ...
  190.                         wmemtool('rmb',win_dw1dtool,n_param_anal,   ...
  191.                                         ind_sig_name,ind_sig_size,  ...
  192.                                         ind_wav_name,ind_lev_anal);
  193.                 levels  = int2str([1:Level_Anal]');
  194.                 cbanapar('set',win_dw1dtool,...
  195.                     'n_s',{Sig_Name,Sig_Size},...
  196.                     'lev',{'String',int2str(Level_Anal)});
  197.                 set(pop_lev_dec,'String',levels,'Value',Level_Anal);
  198.                 set([pop_app_scr,pop_det_scr],'String',levels,'Value',1);
  199.                 dw1dvmod('ini_vm',win_dw1dtool);
  200.             case 'synt'
  201.                 Level_Anal = wmemtool('rmb',win_dw1dtool,n_param_anal,...
  202.                                                         ind_lev_anal);
  203.                 set(pop_lev_dec,'Value',Level_Anal);
  204.                 set([pop_app_scr,pop_det_scr],'Value',1);
  205.                 dw1dvmod('ini_vm',win_dw1dtool);
  206.             case 'anal'
  207.                 Level_Anal = wmemtool('rmb',win_dw1dtool,n_param_anal,...
  208.                                                         ind_lev_anal);
  209.                 levels = int2str([1:Level_Anal]');
  210.                 set(pop_lev_dec,'String',levels,'Value',Level_Anal);
  211.                 set([pop_app_scr,pop_det_scr],'String',levels,'Value',1);
  212.                 dw1dvmod('ini_vm',win_dw1dtool);
  213.         end
  214.     case 'enable'
  215.         % in3 = calling option.
  216.         %--------------------------
  217.         switch in3
  218.             case 'load_sig'
  219.                 cbcolmap('enable',win_dw1dtool,'off')
  220.                 cbanapar('enable',win_dw1dtool,'on');
  221.                 set(pus_anal,'Enable','On' );
  222.             case 'load_cfs'
  223.                 cbcolmap('enable',win_dw1dtool,'off')
  224.                 cbanapar('enable',win_dw1dtool,'on');
  225.                 set(pus_anal,'Enable','On' );
  226.             case {'demo','load_dec'}
  227.                 cbcolmap('enable',win_dw1dtool,'on')
  228.                 cbanapar('enable',win_dw1dtool,'on');
  229.                 set([pus_anal,                              ...
  230.                      pus_deno,    pus_comp,    pus_hist,    ...
  231.                      pus_stat,    pop_viewm,   pus_dispopt, ...
  232.                      pop_app_scr, pop_det_scr, pop_lev_dec  ...
  233.                      ],      ...
  234.                      'Enable','On'   ...
  235.                      );
  236.                 set([m_savesyn, m_savecfs, m_savedec],'Enable','on');
  237.             case {'anal','synt'}
  238.                 cbcolmap('enable',win_dw1dtool,'on')
  239.                 set([pus_deno,    pus_comp,     pus_hist,    ...
  240.                      pus_stat,    pop_viewm,    pus_dispopt, ...
  241.                      pop_app_scr, pop_det_scr,  pop_lev_dec  ...
  242.                      ],...
  243.                      'Enable','on'...
  244.                      );
  245.                 set([m_savesyn, m_savecfs, m_savedec],'Enable','on');
  246.             case {'comp','deno'}
  247.                 set([m_files , pus_anal , pus_deno , pus_comp],'Enable','off');
  248.             case {'return_comp','return_deno'}
  249.                 set([m_files , pus_anal , pus_deno , pus_comp],'Enable','on');
  250.             case {'more_disp','end_more_disp'}
  251.                 hdldynV = dynvtool('handles',win_dw1dtool);
  252.                 btnZaxe = hdldynV.Tog_View_Axes;
  253.                 if isequal(in3,'more_disp') , ena = 'off'; else , ena = 'on'; end
  254. if isequal(in3,'more_disp') , set(btnZaxe,'Enable','Off'); end
  255.                 cbanapar('enable',win_dw1dtool,ena);
  256.                 set([pus_anal,  pus_deno,    pus_comp, ...
  257.                      pop_viewm, pus_dispopt, btnZaxe], ...
  258.                      'Enable',ena ...
  259.                      );
  260.                 lst_subm = get(m_files,'Children');
  261.                 pos_subm = get(lst_subm,'Position');
  262.                 pos_subm = cat(1,pos_subm{:});
  263.                 ind_off  = find(pos_subm<8);
  264.                 set(lst_subm(ind_off),'Enable',ena);
  265. if isequal(in3,'end_more_disp')
  266. dynvtool('dynvzaxe_BtnOnOff',win_dw1dtool);
  267. end
  268.         end
  269.     otherwise
  270.         errargt(mfilename,'Unknown Option','msg');
  271.         error('*');
  272. end