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

📄 ctsiggui.m

📁 ADSP TOOLBOX: Version 2.0 and gui m-files
💻 M
📖 第 1 页 / 共 2 页
字号:
function ctsiggui(mode,ele_loc)
%CTSIGGUI Graphical User Interface program for analog signals & operations


% ADSP Toolbox: Version 2.0 
% For use with "Analog and Digital Signal Processing", 2nd Ed.
% Published by PWS Publishing Co.
%
% Ashok Ambardar, EE Dept. MTU, Houghton, MI 49931, USA
% http://www.ee.mtu/faculty/akambard.html
% e-mail: akambard@mtu.edu
% Copyright (c) 1998


v=matverch;
if v<5,
errordlg('This gui requires MATLAB 5.x and above','Version Error');
return,
end

if nargin == 0, mode = 0; end

if mode ~= 0,
   f = gcf;
   ui = get(f,'userdata');
   stat_bar = ui(61);
   ele_axs = get(ui(12),'userdata');
   ele_mat = get(ui(1),'userdata');
   last_mode = get(stat_bar,'userdata');
   strs = ui(14:3:26);
   edts = ui(15:3:27);
   sig_axs = ui(29);
   opr_axs = ui(32);
   cust_str = ui(62);
   cust_edt = ui(63);
   curs_btn = ui(65);
   curs_dsp = ui(66:69);
end

if mode == 0,
   grey = [0.5,0.5,0.5];
   ltgrey = grey*1.5;
   dkgrey = grey*0.5;
   offwhite = grey*1.9;
   scrn_size = get(0,'screensize');
   fig_w = 620; fig_h = 440;
   flft = (scrn_size(3) - fig_w)/2;
   fbtm = (scrn_size(4) - fig_h)/2;


   ver_str = version;
   ver4    = length(findstr('4.',ver_str));
   if ver4,
      int_str = 'yes';
      f = figure('pos',[flft,fbtm,fig_w,fig_h],'menubar','none',...
            'name','CT Signals and Operations','numbertitle','off',...
            'resize','off','vis','off','interruptible',int_str,...
            'color',dkgrey,'defaultaxesfontsize',10,...
            'defaulttextfontsize',10);
   else
      int_str = 'on';
      eval('f = colordef(''new'',''none'');');
      set(f,'pos',[flft,fbtm,fig_w,fig_h],'menubar','none',...
           'name','CT Signals and Operations','numbertitle','off',...
           'resize','off','vis','off','interruptible',int_str,...
           'color',dkgrey,'defaultaxesfontsize',8,...
           'defaultuicontrolback',[0.5,0.5,0.5],...
           'defaulttextfontsize',8);
   end


%%% OPTIONS:
   uim(1) = uimenu('label','OPTIONS');
   uim(2) = uimenu(uim(1),'label','Help and Info','callback','ctsighlp');
   uim(3) = uimenu(uim(1),'label','Export Data','separator','on',...
                          'callback','ctsiggui(15)');
   uim(4) = uimenu(uim(1),'label','Print Figure','separator','on',...
                          'callback','printdlg(gcf)');
   uim(5) = uimenu(uim(1),'label','Close and Exit','separator','on',...
                          'callback','close(gcf)');
   uim(6) = uimenu('label','   Axis Limits','separator','on',...
                          'callback','ctsiggui(17)');
   uim(7) = uimenu('label','   Zoom ON','separator','on',...
                          'callback','ctsiggui(18)');
   uim(8) = uimenu('label','   Zoom OFF','separator','on',...
                          'callback','ctsiggui(19)');
   uim(9) = uimenu('label','   RESIZE','callback','ctsiggui(20)');


%%%%%%%%


   lft = 190; btm1 = 25; btm2 = 50; btm3 = 75;
   lft2 = 10; btm1a = btm1-4.5+252+138; 
   btm2a = btm1-4.5+107+190-5;
   btma = btm1+287-45-35;

   ui(1) = uicontrol('style','text','pos',[10,btma+78.5-20,126,17],'back',...
     grey,'fore','c','string','Components of x(t)','horiz','left');


   ui(2) = axes('units','pixel','pos',[6,btma-4.5-20,175,102],'box','on',...
            'xtick',[],'ytick',[],'color',ltgrey,'xcolor',ltgrey,...
            'ycolor',ltgrey,'fontsize',10);

   uit = uicontrol('style','slider','pos',[166,btma-6-20,15,103],'min',-1,...
           'max',0,'callback','ctsigedt(4)','vis','off');
   set(ui(2),'userdata',uit);

   uicontrol('style','frame','pos',[5.5,btma-35-20,175,25],...
           'back',grey,'fore',ltgrey);

   btma = btma-31;
   ui(8) = uicontrol('style','text','pos',[lft2,btma-20,55,17],...
           'string','Plot Lim','horiz','right');
   ui(9) = uicontrol('style','edit','pos',[lft2+55,btma-20,47,18],...
           'back','w','string','0,10',...
           'callback','ctsiggui(5)');
   ui(10) = uicontrol('style','text','pos',[lft2+107,btma-20,20,17],...
           'string','dt','userdata',1);
   ui(19) = uicontrol('style','edit','pos',[lft2+127,btma-20,40,18],...
           'back','w','string','0.01','callback','ctsiggui(5)');

   ui(3) =uicontrol('style','frame','pos',[lft2-4.5,btm1a-90,176,95-5+20],...
           'back',grey,'fore',ltgrey);

   ui(4) = uicontrol('style','text','pos',[lft2,btm1a-5,45,20],...
           'string','Signal');
   ui(5) = uicontrol('style','popup','pos',[lft2+49,btm1a-5,120,20],...
           'back','w','string',['General Form|',...
           'Matlab Expn'],'callback','ctsiggui(1)');

   btm4 = btm1a-25;
   ui(11) = uicontrol('style','text','pos',[lft2,btm4,168,17],...
           'string','K*exp(-at)*(t^b)*cos(wt+r)','horiz','left','fore','g');

   btm4 = btm4 -20;
   ui(62) = uicontrol('style','text','pos',[lft2,btm4,25,17],...
           'string','x(t)','vis','off');
   ui(63) = uicontrol('style','edit','pos',[lft2+25,btm4,143,18],...
           'back','w','vis','off');

   ui(14) = uicontrol('style','text','pos',[lft2,btm4,15,17],...
           'horiz','right','string','K');
   ui(15) = uicontrol('style','edit','pos',[lft2+15,btm4,38,18],...
           'back','w','string','2','userdata',0);
   ui(17) = uicontrol('style','text','pos',[lft2+58,btm4,15,17],...
           'horiz','right','string','a');
   ui(18) = uicontrol('style','edit','pos',[lft2+73,btm4,38,18],...
           'back','w','string','1');

   ui(20) = uicontrol('style','text','pos',[lft2+116,btm4,15,17],...
           'horiz','right','string','b');
   ui(21) = uicontrol('style','edit','pos',[lft2+131,btm4,38,18],...
           'back','w','string','0');

   btm4 = btm4-20;
   ui(23) = uicontrol('style','text','pos',[lft2,btm4,15,17],...
           'horiz','right','string','w');
   ui(24) = uicontrol('style','edit','pos',[lft2+15,btm4,48,18],...
           'back','w','string','0');
   ui(26) = uicontrol('style','text','pos',[lft2+68,btm4,45,17],...
           'horiz','right','string','r (rad)');
   ui(27) = uicontrol('style','edit','pos',[lft2+113,btm4,55,18],...
           'back','w','string','0');

   btm4 = btm4-20;
   ui(12) = uicontrol('style','text','pos',[lft2,btm4,15,17],...
           'string','t','userdata',ui(2));
   ui(13) = uicontrol('style','edit','pos',[lft2+15,btm4,55,18],...
           'back','w','string','0,10');
   ui(6) = uicontrol('style','push','pos',[lft2+80,btm4,40,17],...
           'string','ADD','callback','ctsiggui(2)');
   ui(7) = uicontrol('style','push','pos',[lft2+130,btm4,38,17],...
           'string','DEL','callback','ctsigedt(7);ctoplt(0)','enable','off');

   lft = lft - 10;

   ui(36) =uicontrol('style','frame','pos',[5.5,btm1-4.5+116-85,175,98+22],...
           'back',grey,'fore',ltgrey);


   btm2a=btm2a-143-20;
   uicontrol('style','text','pos',[lft2,btm2a,150,17],...
     'string','Operations on x(t)','horiz','left','fore','c');


   btm2a = btm2a - 25;
   ui(50) = uicontrol('style','popup','pos',[lft2,btm2a,167,20],...
           'back','w','string',['y(t)=A + B*x(Ct+D)|Even Part of x(t)|',...
           'Odd Part of x(t)|Running integral of x(t)|Derivative of x(t)'],...
           'callback','ctoplt');


   btm2a = btm2a - 23;
   ui(45) = uicontrol('style','text','pos',[lft2+90,btm2a,18,17],...
           'horiz','right','string','B ');
   ui(46) = uicontrol('style','edit','pos',[lft2+108,btm2a,59,18],...
           'back','w','string','1','callback','ctoplt');

   ui(47) = uicontrol('style','text','pos',[lft2,btm2a,18,17],...
           'horiz','right','string','A ');
   ui(48) = uicontrol('style','edit','pos',[lft2+18,btm2a,60,18],...
           'back','w','string','0','callback','ctoplt');

   btm2a = btm2a - 22;
   ui(43) = uicontrol('style','text','pos',[lft2,btm2a,18,17],...
           'horiz','right','string','C ');
   ui(44) = uicontrol('style','edit','pos',[lft2+18,btm2a,60,18],...
           'back','w','string','1','callback','ctoplt');

   ui(41) = uicontrol('style','text','pos',[lft2+90,btm2a,18,17],...
           'horiz','right','string','D ');
   ui(42) = uicontrol('style','edit','pos',[lft2+108,btm2a,59,18],...
           'back','w','string','0','callback','ctoplt');


   btm2a = btm2a - 22;
   ui(52) = uicontrol('style','push','pos',[lft2+35,btm2a,100,17],...
           'back',ltgrey,'string','Reset Values','callback','ctoplt(6)');


   btm1a=btm2a;
   ui(35) = uicontrol('style','frame','pos',[5.5,btm1a-100+22,175,90-22],...
           'back',grey,'fore',ltgrey,'vis','off');

   uicontrol('style','text','pos',[lft2,btm1a,150,17],...
     'string','Measures for x(t)','horiz','left','fore','c','vis','off');

   ui(53) = uicontrol('style','text','pos',[lft2,btm1a,35,17],...
           'horiz','right','string','Area','vis','off');
   ui(54) = uicontrol('style','text','pos',[lft2+35,btm1a,40,17],...
           'back',offwhite,'vis','off');

   ui(59) = uicontrol('style','text','pos',[lft2+80,btm1a,47,17],...
           'horiz','right','string','Energy','vis','off');
   ui(60) = uicontrol('style','text','pos',[lft2+127,btm1a,40,17],...
           'back',offwhite,'vis','off');
   ui(55) = uicontrol('style','text','pos',[lft2,btm1a,95,17],...
           'horiz','right','string','Absolute Area','vis','off');
   ui(56) = uicontrol('style','text','pos',[lft2+95,btm1a,70,17],...
           'back',offwhite,'vis','off');

   btm1a = btm1a - 30;
   ui(65) = uicontrol('style','check','pos',[lft2+100,btm1a,70,20],...
           'string','Cursor','back','y','callback','ctsiggui(9)');

   ui(61) = uicontrol('style','text','pos',[5,1,610,17],'horiz','left',...
           'userdata',0,'fore','m','back','y');



   pos = get(f,'pos');
   lef = pos(3)-166;
   bot = pos(4)-21;

   ui(66) = uicontrol('style','text','pos',[lef,bot,20,20],...
           'string','X ','horiz','right');
   ui(67) = uicontrol('style','text','pos',[lef+20,bot,60,20],...
           'string','','back','w');
   ui(68) = uicontrol('style','text','pos',[lef+85,bot,20,20],...
           'string','Y ','horiz','right');
   ui(69) = uicontrol('style','text','pos',[lef+105,bot,60,20],...
           'string','','back','w');
   set(ui(66:69),'vis','off');


   ui(29) = axes('units','pixel','pos',[210,260,390,155],'box','on',...
            'color','k','xcolor','w','ycolor','w','xgrid','on','ygrid','on');
   title('Signal  x(t)');
   xlabel('Time  [t]')
   ui(30) = line('xdata',0,'ydata',0,'color','y');
   set(ui(29),'userdata',ui(30));

   ui(32) = axes('units','pixel','pos',[210,50,390,155],'box','on',...
            'color','k','xcolor','w','ycolor','w','xgrid','on','ygrid','on');
   xlabel('Time  [t]')
   ui(33) = line('xdata',0,'ydata',0,'color','g');
   set(ui(32),'userdata',ui(33));


% need to store the two axis handles
   set(ui(6),'userdata',ui(29));
   set(ui(7),'userdata',ui(32));
   set(f,'userdata',ui);
   ctsigplt(1);
   ctoplt;
   ctsiggui(2);
   drawnow;
   set(f,'vis','on');


elseif any(mode == [1,8]), % popup selection
   val = get(ui(5),'value');
   set(stat_bar,'userdata',mode);

   if mode == 1, % popup selection
      if length(get(ui(14),'userdata')),
         set(get(ele_axs,'chil'),'color','k');
      end
      set(stat_bar,'string','Mode: ADD. Change values and click on Add.');
      set(ui(13),'string','0,10');
      set(ui(14),'userdata',[]);
      set(ui(3),'userdata',[]);
      set(ui(7),'enable','off'); set(ui(6),'enable','on');
      set([edts,ui(13),cust_edt],'callback','');
   else
set(stat_bar,'string','EDIT values & click on item or click DEL to delete.');
      set(ui(7),'enable','on'); set(ui(6),'enable','off');
      set([edts,ui(13),cust_edt],'callback','ctsigedt(6)');
   end

   if val == 1, % Exponential
      set(ui(11),'string','K*exp(-at)*(t^b)*cos(wt+r)');
   elseif val == 2,
      set(ui(11),'string','Example:  t .* exp(-pi*t.*t)');
   end


   if val == 1,
      set([strs,edts],'vis','on');
      set([cust_str,cust_edt],'vis','off');

      if mode == 1,
         set(edts,'enable','on');
      else
         ele_mat = get(ui(1),'userdata');

⌨️ 快捷键说明

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