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

📄 dpzgui.m

📁 ADSP TOOLBOX: Version 2.0 and gui m-files
💻 M
📖 第 1 页 / 共 2 页
字号:
%   axis('equal');
   fr=0:1/360:1;
   phi=fr*2*pi;
   cir=exp(sqrt(-1)*phi);
   set(ui(26),'xdata',real(cir),'ydata',imag(cir))
   set(ui(23),'userdata',ui(24:26));

   ui(27) = axes('units','pixel','pos',[430,240+20,160,160],'box','on',...
            'xlim',[-0.5,0.5],'color','k',...
             'xgrid','on','ygrid','on');
   title('Magnitude Spectrum');
   xlabel('Digital Frequency  [F]');
   ui(28) = line('xdata',0,'ydata',0,'color','y','erase','back');
   set(ui(27),'userdata',ui(28));


   ui(29) = axes('units','pixel','pos',[430,35+16,160,160],'box','on',...
            'xlim',[-0.5,0.5],'color','k',...
             'xgrid','on','ygrid','on');
   title('Unwrapped Phase [deg]');
   xlabel('Digital Frequency  [F]');
   ui(30) = line('xdata',0,'ydata',0,'color','y','erase','back');
   set(ui(29),'userdata',ui(30));
   set(ui(3),'userdata',ui(10));



   set(f,'userdata',ui);
   set(ui(1),'userdata',[]);
   dpzgui(2);
   drawnow;
   set(f,'vis','on');

elseif mode == 2, % adding
   val1 = get(edts(1),'value');
   val2 = str2num(get(edts(2),'string'));
   val3 = str2num(get(edts(3),'string'));
   val4 = str2num(get(edts(4),'string'));
   if ~length(val4),
      val4=0;
   end
   if ~length(val2)|~length(val3),
      errordlg('You must enter a VALID number.','Input Error');
      return;
   end

   if rem(val2,1) | val2<1
      errordlg('Multiplicity must be a positive integer.','Input Error');
      return;
   end

   val_vec = [val1, val2, val3, val4];
   ele_mat = [ele_mat;val_vec];
   set(ui(1),'userdata',ele_mat);
   dpzplt;
   dpzedt(1);


elseif mode == 3, % edit 
   edt = gco;
   if edt~=ui(6) & edt ~=ui(12)
   edt_val = str2num(get(edt,'string'));
   if ~length(edt_val),
      errordlg('You must enter a VALID number.','Input Error');
      return;
   end
   end


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

    set(f,'WindowButtonMotionFcn','dpzgui(7)');

    else

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


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


elseif mode == 7, % 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


%%%%%% PASTE AT END before last end statement %%%%%%%%%%%%%
elseif mode == 15, %Export data
dpzplt;
fstr=get(ui(33),'string');fval=get(ui(33),'value');fstr=fstr(fval,:); %Hz
hstr=get(ui(47),'string');hval=get(ui(47),'value');hstr=hstr(hval,:);%h[n]

str1='Export transfer function numerator as';
str2='Export transfer function denominator as';
str3='Export gain as';
str4='Export phase (deg) as';
str5=['Export digital frequency ' fstr ' as'];
str6=['Export ' hstr ' (symbolic) as'];

exp_str={str1,str2,str3,str4,str5,str6};
exp_var={'Numpz','Denpz','gainpz','phasepz','freqpz','nresp'};
expect=inputdlg(exp_str,'Save Variables as',1,exp_var);
if ~isempty(expect)
na=get(ui(15),'userdata');%%% FIX FOR UIs 
da=get(ui(16),'userdata');%%% FIX FOR UIs 
fm=get(ui(17),'userdata');
fp=get(ui(18),'userdata');
ht=get(ui(19),'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
if ~isempty(expect{6}),assignin('base',expect{6},ht);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),dpzgui(16);
else
set(curs_btn,'value',0);
dpzgui(6); 
if any(cur_axs==ui([20,23,27,29]))
if cur_axs==ui(20),txt=get(ui(20),'userdata'); 
elseif cur_axs==ui(29),txt='Transfer Function Phase';
elseif cur_axs==ui(27),txt='Transfer Function Gain';
elseif cur_axs==ui(23),txt='Pole-Zero Plot';
end
axlimdlg(txt,[1 1]); %[1 1]=auto +linear/log,  [1 0]=auto, no linear/log
else
dpzgui(16);
end
end


elseif mode == 18, % zoom on
set(curs_btn,'value',0);
dpzgui(6);                    % 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);
dpzgui(6);                    % Use CURSOR MODE 
if get(ui(5),'userdata')==1

%%%%%Insert old zoom off here
set(f,'currentaxes',ui(20));
zoom out,zoom reset,zoom off
set(f,'currentaxes',ui(23));
zoom out,zoom reset,zoom off
set(f,'currentaxes',ui(27));
zoom out,zoom reset,zoom off
set(f,'currentaxes',ui(29));
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),dpzgui(16);return,end

   if any(cur_axs == [sig_axs,mag_axs,phs_axs,pz_axs]),
      axes(cur_axs);
         axs_pos = get(cur_axs,'pos');
         if axs_pos(4) == 160, % need to maximize
            set(mag_axs,'pos',[-600 35+16 160 160]);
            set(phs_axs,'pos',[-600 35+16 160 160]);
            set(pz_axs,'pos',[-600 240+20 160 160]);
            set(sig_axs,'pos',[-600 240+20 160 160]);
            if cur_axs==pz_axs
            set(cur_axs,'pos',[210 35+16 375 375]);
            else
            set(cur_axs,'pos',[210 35+16 400 365]);
            end
         else % minimization
            set(mag_axs,'pos',[430 240+20 160 160]);
            set(phs_axs,'pos',[430 35+16 160 160]);
            set(pz_axs,'pos',[220 240+20 160 160]);
            set(sig_axs,'pos',[220 35+16 160 160]);
         end
   else
         dpzgui(16);
   end


end

⌨️ 快捷键说明

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