⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cw1dtool.m

📁 非常有用的matlab cheng xu
💻 M
📖 第 1 页 / 共 2 页
字号:
function varargout = cw1dtool(option,varargin)
%CW1DTOOL Continuous Wavelet 1-D tool (Real case).
%   VARARGOUT = CW1DTOOL(OPTION,VARARGIN)

%   M. Misiti, Y. Misiti, G. Oppenheim, J.M. Poggi 12-Mar-96.
%   Last Revision: 16-Jan-2001.
%   Copyright 1995-2002 The MathWorks, Inc.
% $Revision: 1.19 $

% Test inputs.
%-------------
if nargin==0 , option = 'create'; end
[option,winAttrb] = utguidiv('ini',option,varargin{:});

% Default values.
%----------------
max_lev_anal = 12;
default_nbcolors = 128;

% Memory bloc of stored values.
%==============================
% MB0.
%-----
n_InfoInit   = 'InfoInit';
ind_filename = 1;
ind_pathname = 2;
nb0_stored   = 2;

% MB1.
%-----
n_param_anal   = 'Par_Anal';
ind_sig_name   = 1;
ind_sig_size   = 2;
ind_wav_name   = 3;
ind_lev_anal   = 4;
ind_act_option = 5;
ind_gra_area   = 6;
nb1_stored     = 6;

% MB2.
%-----
n_coefs_sca    = 'Coefs_Scales';
ind_coefs      = 1;
ind_scales     = 2;
ind_frequences = 3;
ind_sca_OR_frq = 4;
nb2_stored     = 4;

switch option
    case 'create'

        % Get Globals.
        %-------------
        [Def_Txt_Height,Def_Btn_Height,Def_Btn_Width,  ...
         Pop_Min_Width,X_Spacing,Y_Spacing,            ...
         Def_TxtBkColor,Def_EdiBkColor,Def_FraBkColor  ...
         ] = mextglob('get',...
              'Def_Txt_Height','Def_Btn_Height','Def_Btn_Width', ...
              'Pop_Min_Width','X_Spacing','Y_Spacing',           ...
              'Def_TxtBkColor','Def_EdiBkColor','Def_FraBkColor' ...
              );

        % window creation.
        %-----------------
        win_title = 'Continuous Wavelet 1-D';
        [win_tool,pos_win,win_units,str_numwin,...
            fra_hdl,pos_fra,Pos_Graphic_Area,pus_close] = ...
               wfigmngr('create',win_title,winAttrb,...
                  'ExtFig_Tool_3',mfilename,1,1,0);
        if nargout>0 , varargout{1} = win_tool; end
		
		% Add Help for Tool.
		%------------------
		wfighelp('addHelpTool',win_tool,'&Continuous Analysis','CW1D_GUI');

		% Add Help Item.
		%----------------
		wfighelp('addHelpItem',win_tool,'Continuous Transform','CW_TRANSFORM');
		wfighelp('addHelpItem',win_tool,'Continuous Versus Discrete (1)','CW_CONTDISC1');	
		wfighelp('addHelpItem',win_tool,'Continuous Versus Discrete (2)','CW_CONTDISC2');
		wfighelp('addHelpItem',win_tool,'Loading and Saving','CW_LOADSAVE');
		
		% Set 'WindowButtonUpFcn' function.
		%---------------------------------
		cb_up = ['cw1dmngr(''WindowButtonUpFcn'',' str_numwin ')'];
		set(win_tool,'WindowButtonUpFcn',cb_up);

		% Menu construction for current figure.
        %--------------------------------------
	    m_files = wfigmngr('getmenus',win_tool,'file');	
        men_load = uimenu(m_files,...
                         'Label','&Load Signal ', ...
                         'Position',1,           ...
                         'Callback',             ...
                         ['cw1dmngr(''load'',' str_numwin ');'] ...
                         );

        men_save = uimenu(m_files,...
                         'Label','&Save Coefficients ',...
                         'Position',2,                ...
                         'Enable','Off',              ...
                         'Callback',                  ...
                          ['cw1dmngr(''save'',' str_numwin ');'] ...
                          );

        men_demo = uimenu(m_files,...
                         'Label','&Example Analysis ','Position',3);

        demoSET = {...
          'Test Singuralities (I)' , ...
              'cuspamax' , 'haar' , 1 , [1,1,64]  , 128 ; ...
          'Test Singuralities (II)' , ...
              'cuspamax' , 'sym4' , 1 , [1,1,64]  , 128 ; ...
          'Near Breaks (I)' , ...
              'brkintri' , 'coif4'  1 , [1,1,64]  , 128 ; ...
          'Near Breaks (II)' , ...
              'brkintri' , 'gaus4', 1 , [1,1,64]  , 128 ; ...
          'Cantor curve', ...
              'wcantor'  , 'haar' , 1 , [1,1,64]  ,  16 ; ...
          'Cantor curve' , ...
              'wcantor'  , 'meyr' , 1 , [1,1,32]  ,  16 ; ...
          'Cantor curve (non-abs. cfs)' , ...
              'wcantor'  , 'morl' , 2 , [1,1,32]  , 128 ; ...
          'Koch curve' , ...
              'vonkoch'  , 'sym4' , 1 , [1,2,32]  , 128 ; ...
          'Koch curve' , ...
              'vonkoch'  , 'mexh' , 1 , [1,2,32]  , 128 ; ...
          'Koch curve (non-abs. cfs)' , ...
              'vonkoch'  , 'mexh' , 2 , [1,2,32]  , 128 ; ...
          'Frequency breakdown' , ...
              'freqbrk'  , 'sym4' , 1 , [1,1,64]  , 128 ; ...
          'Frequency breakdown' , ...
              'freqbrk'  , 'mexh' , 1 , [1,1,32]  , 128 ; ...
          'Frequency breakdown (non-abs. cfs)' , ...
              'freqbrk'  , 'mexh' , 2 , [1,1,32]  , 128 ; ...
          'Electrical consumption' , ...
              'leleccum' , 'sym6' , 1 , [1,1,32]  , 128 ; ...
          'Noisy sine' , ... 
              'noissin'  , 'db4'  , 2 , [1,1,48]  , 128   ...
          };
        beg_call_str = ['cw1dmngr(''demo'',' str_numwin ','''];
        nbDEM = size(demoSET,1);
        for k=1:nbDEM
            nam  = demoSET{k,1};
            fil  = demoSET{k,2};
            wav  = demoSET{k,3};
            colm = demoSET{k,4};
            val  = demoSET{k,5};
            nbcol = demoSET{k,6};
            scales = ['[' num2str(val(1)) ':' num2str(val(2)) ...
                            ':' num2str(val(3)) ']'];
            libel = ['with ' wav '   at scales  ' scales ...
                            '  -->  ' nam];
            action = [beg_call_str fil ''',''' wav ''','  ...
                    num2str(val(1)) ',' num2str(val(2)) ',' ...
                    num2str(val(3)) ',' sprintf('%.0f',colm) ',' ...
                    int2str(nbcol) ');'];
            uimenu(men_demo,'Label',libel,'Callback',action);
        end

        % Begin waiting.
        %---------------
        wwaiting('msg',win_tool,'Wait ... initialization');

        % General graphical parameters initialization.
        %--------------------------------------------
        x_frame   = pos_fra(1);
        cmd_width = pos_fra(3);
        dx = X_Spacing;
        dy = Y_Spacing; dy2 = 2*dy;        
        d_txt = (Def_Btn_Height-Def_Txt_Height);
        pop_width = pos_fra(3)-8*dx;

        % Command part of the window.
        %============================
        % Data, Wavelet and Level parameters.
        %------------------------------------
        xlocINI = pos_fra([1 3]);
        ytopINI = pos_win(4)-dy;
        toolPos = utanapar('create',win_tool, ...
                    'levflag',0, ...
                    'xloc',xlocINI,'top',ytopINI,...
                    'enable','off', ...
                    'wtype','cwt',            ...
                    'maxlev',max_lev_anal  ...
                    );

        % Adding colormap GUI.
        %---------------------
        utcolmap('create',win_tool, ...
                 'xloc',xlocINI, ...
                 'enable','off', ...
                 'bkcolor',Def_FraBkColor);
        colmapPos = utcolmap('position',win_tool);

        % Setting Initial Colormap.
        %--------------------------
        cbcolmap('set',win_tool,'pal',{'pink',default_nbcolors})

        % UIC construction.
        %------------------------------------------------------------------
        y_low       = toolPos(2);
        h_fra       = Def_Btn_Height+2*dy;
        y_fra       = y_low-h_fra-dy2;
        pos_fra_sam = [toolPos(1),y_fra,toolPos(3),h_fra];
        y_low       = pos_fra_sam(2)+dy;
        x_uic       = toolPos(1)+dx;
        w_uic       = Pop_Min_Width;
        pos_txt_sam = [x_uic, y_low+d_txt/2, 2*w_uic, Def_Txt_Height];
        x_uic       = x_uic+pos_txt_sam(3);
        pos_edi_sam = [x_uic, y_low , w_uic, Def_Btn_Height] ;      
        %------------------------------------------------------------------
        h_fra       = 4*Def_Btn_Height+7*dy;
        y_fra       = pos_fra_sam(2)-h_fra-2*dy2;
        pos_fra_sca = [toolPos(1),y_fra,toolPos(3),h_fra];
        y_low       = y_fra+dy;
        %------------------------------------------------------------------
        x_left_1    = x_frame+2*dx;
        x_left_2    = x_frame+(cmd_width-pop_width)/2;
        y_uic       = pos_fra_sca(2)+pos_fra_sca(4)-dy;
        w_uic       = 1.5*Pop_Min_Width;        
        x_uic       = toolPos(1)+(toolPos(3)-w_uic)/2;
        pos_txt_sca = [x_uic, y_uic, w_uic, Def_Txt_Height];
        y_low       = pos_txt_sca(2)-Def_Btn_Height-dy;
        pos_pop_sca = [x_left_2, y_low, pop_width, Def_Btn_Height];
        %------------------------------------------------------------------
        deltay      = Def_Btn_Height+dy;
        w_txt       = pos_pop_sca(3)/2+2*dx;
        w_edi       = pos_pop_sca(3)/2-2*dx;
        y_low       = pos_pop_sca(2)-Def_Btn_Height-dy2;
        pos_txt_min = [x_left_1, y_low+d_txt/2, w_txt, Def_Txt_Height];
        pos_edi_min = [x_left_1+w_txt, y_low, w_edi, Def_Btn_Height];
        pos_txt_stp = pos_txt_min; pos_txt_stp(2) = pos_txt_stp(2)-deltay;
        pos_edi_stp = pos_edi_min; pos_edi_stp(2) = pos_edi_stp(2)-deltay;
        pos_txt_max = pos_txt_stp; pos_txt_max(2) = pos_txt_max(2)-deltay;
        pos_edi_max = pos_edi_stp; pos_edi_max(2) = pos_edi_max(2)-deltay;
        %------------------------------------------------------------------
        w_txt       = (2*Def_Btn_Width)/3;
        pos_txt_pow = [x_left_1, y_low+d_txt/2, w_txt, Def_Txt_Height];
        xl          = pos_txt_pow(1)+pos_txt_pow(3)+dx;
        pos_pop_pow = [xl, y_low, Pop_Min_Width, Def_Btn_Height];
        %------------------------------------------------------------------
        pos_txt_msc = [x_left_1, y_low , pos_pop_sca(3), Def_Txt_Height];
        y_low       = y_low-Def_Btn_Height-dy;
        pos_edi_msc = [x_left_2, y_low , pos_pop_sca(3), Def_Btn_Height];
        %------------------------------------------------------------------
        w_uic       = 1.5*Def_Btn_Width;
        y_uic       = 1.5*Def_Btn_Height;
        y_low       = pos_fra_sca(2)-y_uic-3*dy;
        x_uic       = toolPos(1)+(toolPos(3)-w_uic)/2;
        pos_pus_ana = [x_uic,y_low,w_uic,y_uic];
        %------------------------------------------------------------------

        %------------------------------------------------------------------
        y_fra       = colmapPos(2)+colmapPos(4)+3*dy;
        h_fra       = Def_Btn_Height+3*dy;        
        pos_fra_ccm = [toolPos(1),y_fra,toolPos(3),h_fra];
        y_low       = y_fra+dy;
        pos_pop_ccm = [toolPos(1)+dx,y_low,toolPos(3)-2*dx,Def_Btn_Height];
        y_low       = y_low+Def_Btn_Height+dy/2;
        w_uic       = 1.5*Def_Btn_Width;
        x_uic       = toolPos(1)+(toolPos(3)-w_uic)/2;
        pos_txt_ccm = [x_uic, y_low, w_uic, Def_Txt_Height];
        %------------------------------------------------------------------
        y_low       = pos_fra_ccm(2)+pos_fra_ccm(4)+2*dy2;
        x_uic       = toolPos(1);
        w_uic       = (toolPos(3)-dx)/2;
        pos_rad_SCA = [x_uic, y_low, w_uic, Def_Btn_Height];
        x_uic       = x_uic+w_uic+dx;
        pos_rad_FRQ = [x_uic, y_low, w_uic, Def_Btn_Height];
        %------------------------------------------------------------------
        y_fra       = pos_rad_SCA(2)+pos_rad_SCA(4)+dy2;
        h_fra       = 3*Def_Btn_Height+3*dy;
        w_uic       = 2*Def_Btn_Width;
        w_fra       = w_uic+2*dx;
        x_fra       = toolPos(1)+(toolPos(3)-w_fra)/2; 
        pos_fra_axe = [x_fra,y_fra,w_fra,h_fra];
        y_low       = y_fra+dy;
        x_uic       = x_fra+dx;
        pos_chk_LML = [x_uic, y_low, w_uic, Def_Btn_Height];
        y_low       = y_low+Def_Btn_Height;
        pos_chk_LC  = [x_uic, y_low, w_uic, Def_Btn_Height];
        y_low       = y_low+Def_Btn_Height;
        pos_chk_DEC = [x_uic, y_low, w_uic, Def_Btn_Height];
        y_low       = y_low+Def_Btn_Height;
        w_uic       = 1.25*Def_Btn_Width;
        x_uic       = toolPos(1)+(toolPos(3)-w_uic)/2; 
        pos_txt_axe = [x_uic, y_low, w_uic, Def_Txt_Height];
        %------------------------------------------------------------------
        y_low       = pos_fra_axe(2)+pos_fra_axe(4)+2*dy2;
        xg          = x_frame+(cmd_width-pop_width)/2;
        pos_pus_ref = [xg,y_low,pop_width,Def_Btn_Height];
        y_low       = y_low+Def_Btn_Height;
        pos_pus_lin = [xg,y_low,pop_width,Def_Btn_Height];
        %------------------------------------------------------------------

        % String property of objects.
        %----------------------------
        str_txt_sam = 'Sampling Period:';
        str_txt_sca = 'Scale Settings';
        str_pop_sca = ...
            strvcat('Step by Step Mode','Power 2 Mode','Manual Mode'); 
        str_pus_ana = 'Analyze';
        str_pus_lin = 'New Coefficients Line';
        str_pus_ref = 'Refresh Maxima Lines';

        str_txt_min = 'Min  ( > 0)';
        str_txt_stp = 'Step ( > 0 )';
        str_txt_max = 'Max     ';

        str_txt_pow = 'Power';
        str_pop_pow = int2str([1:max_lev_anal]');
        str_txt_msc = 'Scales : MATLAB Vector';

        str_txt_axe = 'Selected Axes';
        str_chk_LML = 'Maxima Lines';
        str_chk_LC  = 'Coefficients Line';
        str_chk_DEC = 'Coefficients';

        str_rad_SCA = 'Scales';

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -