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

📄 idealgui.m

📁 ADSP TOOLBOX: Version 2.0 and gui m-files
💻 M
📖 第 1 页 / 共 2 页
字号:
   set(f,'userdata',ui);
   idealplt;
   drawnow;
   set(f,'vis','on');


elseif mode == 1, % filter popup
   filter_type = get(filter_pop,'value');
      set(cutoff_edt,'enable','on');
   if get(autoplot,'value'), idealplt; end

elseif mode == 2, % window popup
   window_type = get(window_pop,'value');

   if any(window_type == [(1:4)]),
      set([beta_uis,ripple_uis,harris_uis],'vis','off');

   elseif window_type == 5, %Kaiser
      set(beta_uis,'vis','on');
      set(ripple_uis,'vis','off');
      set(harris_uis,'vis','off');

   elseif window_type == 6, %Cheby
      set(ripple_uis,'vis','on');
      set(beta_uis,'vis','off');
      set(harris_uis,'vis','off');

   elseif window_type == 7, % Harris
      set(ripple_uis,'vis','off');
      set(beta_uis,'vis','off');
      set(harris_uis,'vis','on');

   end
   if get(autoplot,'value'), idealplt; end

elseif mode == 3, % edit fields
   window_type = get(window_pop,'value');
   edt = gco;

   if any(edt == [n_uis(2),harris_uis(2),...
                  beta_uis(2),ripple_uis(2)]),
      edt_val = eval(['[',get(edt,'string'),']'],'[]');

      if ~length(edt_val),
         errordlg('You must enter a VALID number.','Input Error');
         return;

      elseif edt == ripple_uis(2), % inspect cheb ripple
         if edt_val <= 0,
            errordlg('Ripple must be a positive value.','Input Error');
            return;
         end

      elseif edt == harris_uis(2), % inspect harris type
         if edt_val < 0 | edt_val > 7 | rem(edt_val,1)~=0,
            errordlg('Enter integer type form 0 to 7.','Input Error');
            return;
         else
            edt_val = floor(edt_val);
         end

      end

      set(edt,'string',num2str(edt_val));
   end
   if get(autoplot,'value'), idealplt; end

elseif mode == 4,
   k_str=get(ui(6),'string');
      k_val= eval(['[',k_str,']'],[]);
        if isempty(k_val),
        errordlg('Matlab syntax error.','Input Error');
        return
        end
        if rem(k_val,1)|k_val<2,
        errordlg('# of harmonics must be an integer >= 2.','Input Error');
        return
        end
   k_val=k_val-1;if k_val<2,k_val=2;end
   if ~rem(k_val,2)
   window_type = get(window_pop,'value');
   filter_type = get(filter_pop,'value');
     if rem(filter_type,2)==0 | window_type==6
        k_val=max(3,k_val-1);
     end
   end

   k_str=int2str(k_val);
   set(ui(6),'string',k_str);
   idealplt;

elseif mode == 10,
   k_str=get(ui(6),'string');
      k_val= eval(['[',k_str,']'],[]);
        if isempty(k_val),
        errordlg('Matlab syntax error.','Input Error');
        return
        end
        if rem(k_val,1) %|k_val<2,
        errordlg('# of harmonics must be an integer >= 2.','Input Error');
        return
        end
   if rem(k_val,2)
   window_type = get(window_pop,'value');
   filter_type = get(filter_pop,'value');
     if rem(filter_type,2)==0 | window_type==6
        k_val=k_val+1;
     end
   end
   k_str=int2str(k_val+1);
   set(ui(6),'string',k_str);
   idealplt;

elseif mode == 5, % auto plot
   if get(autoplot,'value'),
      set(plot_btn,'enable','off');
      idealplt;
   else
      set(plot_btn,'enable','on');
   end

elseif mode == 6, % linear/db
   if get(ui(32),'value')==1
      set([ui(34),ui(35)],'vis','off');
   else
      set([ui(34),ui(35)],'vis','on');
   end
      idealplt;


elseif mode == 8, % cursor
    if get(curs_btn,'value')
    set(curs_dsp,'vis','on');

    set(f,'WindowButtonMotionFcn','idealgui(9)');

    else

  set(f,'Pointer','arrow','WindowButtonMotionFcn','');


   set(curs_dsp,'vis','off')
   set(curs_btn,'value',0),

    end


elseif mode == 9, % cursor movement
       h=gca;
       set(f,'currentaxes',h);
       lim=get(h,'pos');  % get current axis position
       c_p = [lim(1) lim(1)+lim(3) lim(2) lim(2)+lim(4)];
       f_p=get(f,'CurrentPoint'); % get co-ordinates of current point

     if f_p(1) < c_p(1) | f_p(1) > c_p(2) | f_p(2) < c_p(3) | f_p(2) > c_p(4)
        set(f,'Pointer','arrow');

        set(curs_dsp(2),'string','');
        set(curs_dsp(4),'string','');

     else
        curr_pt=get(h,'CurrentPoint');  % get current mouse position
        set(f,'Pointer','crosshair');
        set(curs_dsp(2),'string',num2str(curr_pt(1,1)));
        set(curs_dsp(4),'string',num2str(curr_pt(1,2)));
     end


elseif mode == 15, %Export data
idealplt;
mstr=get(ui(32),'string');mval=get(ui(32),'value');mstr=mstr(mval,:);%dB
if mval==2,mstr=['normalized ' mstr];end

str1='Export window coefficients as';
str2='Export windowed filter coefficients as';
str3=['Export ' mstr ' gain of window as'];
str4=['Export ' mstr ' gain of filter as'];
str5='Export digital frequency F as';

exp_str={str1,str2,str3,str4,str5};
exp_var={'hwin','hfilt','magwin','magfilt','digifreq'};
expect=inputdlg(exp_str,'Save Variables as',1,exp_var);
if ~isempty(expect)
na=get(ui(44),'userdata');%%% FIX FOR UIs 
da=get(ui(45),'userdata');%%% FIX FOR UIs 
fm=get(ui(46),'userdata');
fp=get(ui(47),'userdata');

if ~isempty(expect{1}),assignin('base',expect{1},na);end
if ~isempty(expect{2}),assignin('base',expect{2},da);end
if ~isempty(expect{3}),assignin('base',expect{3},fm(:,2));end
if ~isempty(expect{4}),assignin('base',expect{4},fp);end
if ~isempty(expect{5}),assignin('base',expect{5},fm(:,1));end
end



elseif mode == 16, % Axis Control Help
msgbox([' First click in a plot window.                             ',... 
'                  Then, come back and execute'],...
'Axis Control Info','help')

elseif mode == 17, % Axis Control
cur_axs=[];   cur_obj = gco;
   cur_par = get(cur_obj,'parent');
if ~isempty(cur_par)
   if cur_par == f,
      cur_axs = cur_obj;
   else
      cur_axs = cur_par;
   end
end

if isempty(cur_axs),idealgui(16);
else
set(curs_btn,'value',0);
idealgui(8); %%% REPLACE number BY CURSOR MODE 
if any(cur_axs==ui([23,36,38,41])),%%%% CHANGE UI numbers
if cur_axs==ui(23),txt='Windowed filter spectrum';%%%% CHANGE UI numbers
elseif cur_axs==ui(36),txt='Window spectrum';%%%% CHANGE UI numbers
elseif cur_axs==ui(38),txt='Window function';%%%% CHANGE UI numbers
elseif cur_axs==ui(41),txt='Windowed impulse response';%%%% CHANGE UI numbers
end
axlimdlg(txt,[1 1]); %[1 1]=auto +linear/log,  [1 0]=auto, no linear/log
else
idealgui(16);
end
end


elseif mode == 18, % zoom on
set(curs_btn,'value',0);
idealgui(8);                    % Use CURSOR MODE 
if get(ui(5),'userdata')==0  %%Change ui(15) to whatever
zoom on
set(ui(5),'userdata',1);
else
msgbox('Zoom is already ON.','Zoom Info','help')
end

elseif mode == 19, % zoom off
set(curs_btn,'value',0);
idealgui(8);                    % Use CURSOR MODE 
if get(ui(5),'userdata')==1

%%%%%Insert old zoom off here
set(f,'currentaxes',ui(23));
zoom out,zoom reset,zoom off
set(f,'currentaxes',ui(36));
zoom out,zoom reset,zoom off
set(f,'currentaxes',ui(38));
zoom out,zoom reset,zoom off
set(f,'currentaxes',ui(41));
zoom out,zoom reset,zoom off
set(ui(5),'userdata',0);
else
msgbox('Zoom is already OFF.','Zoom Info','help')
end



elseif mode == 20, % mouse functionality
cur_axs = [];   cur_obj = gco;
   cur_par = get(cur_obj,'parent');


if ~isempty(cur_par)
   if cur_par == f,
      cur_axs = cur_obj;
   else
      cur_axs = cur_par;
   end
end


if isempty(cur_axs),idealgui(16);return,end

   if any(cur_axs == [mag_axs,phs_axs,pz_axs,sig_axs]),
      axes(cur_axs);
         axs_pos = get(cur_axs,'pos');
         if axs_pos(4) == 160, % need to maximize
            set(mag_axs,'pos',[-600 35 160 160]);
            set(phs_axs,'pos',[-600 35 160 160]);
            set(pz_axs,'pos',[-600 240+6 160 160]);
            set(sig_axs,'pos',[-600 240+6 160 160]);
            set(cur_axs,'pos',[210,35,400,365]);

         else % minimization
            set(mag_axs,'pos',[430 35 160 160]);
            set(phs_axs,'pos',[220 35 160 160]);
            set(pz_axs,'pos',[220 240+6 160 160]);
            set(sig_axs,'pos',[430 240+6 160 160]);

         end
   else
         idealgui(16);
   end

end

⌨️ 快捷键说明

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