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

📄 dfftgui.m

📁 ADSP TOOLBOX: Version 2.0 and gui m-files
💻 M
📖 第 1 页 / 共 2 页
字号:
function dfftgui(mode,ele_loc)
%DFFTGUI Graphical User Interface program for the FFT and windowing.


% 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

% Assisted by Craig Borghesani
% http://world.std.com/~borg/


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');
   last_mode2 = get(ui(17),'userdata');
   strs = ui(14:3:20);
   edts = ui(15:3:21);
   top_axs = ui(29);
   window_pop  = ui(34);
   beta_uis    = ui(62:63);
   ripple_uis  = ui(64:65);
   harris_uis  = ui(66:67);
   range_edt = ui(52);
   mag1_edt = ui(4);
   mag2_edt = ui(5);
   sig_axs = ui(35);
   fft_axs = ui(40);
   win_axs = ui(43);
   curs_btn = ui(54);
   curs_dsp = ui(55:58);
   autoplot = ui(59);
   plot_btn = ui(60);
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 = 450;
   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','FFT of Sinusoids','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','FFT of Sinusoids','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','dffthlp');
   uim(3) = uimenu(uim(1),'label','Export Data','separator','on',...
                          'callback','dfftgui(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','dfftgui(17)');
   uim(7) = uimenu('label','   Zoom ON','separator','on',...
                          'callback','dfftgui(18)');
   uim(8) = uimenu('label','   Zoom OFF','separator','on',...
                          'callback','dfftgui(19)');
   uim(9) = uimenu('label','   RESIZE','callback','dfftgui(20)');


%%%%%%


   lft = 10; btm = fig_h - 15 - 102+5+5;
   ui(1) = uicontrol('style','text','pos',[lft,btm+83,156,17],'back',grey,...
             'fore','c','string','Analog Sinusoid(s)','horiz',...
             'left','callback','dfftgui(6)','value',1);
   ui(2) = axes('units','pixel','pos',[6,btm,175,102],'box','on',...
            'xtick',[],'ytick',[],'color',ltgrey,'xcolor',ltgrey,...
            'ycolor',ltgrey);

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

   ui(3) = uicontrol('style','frame','pos',[5,btm-126+52,175,121-52],...
           'back',grey,'fore',ltgrey);

   btm = btm - 30;
   ui(11) = uicontrol('style','text','pos',[lft,btm,165,20],...
           'horiz','center','fore','g','string','M cos(2pi*f*t + P[deg])');

   btm = btm - 20;
   ui(14) = uicontrol('style','text','pos',[lft,btm,15,17],...
           'horiz','left','string','M');
   ui(15) = uicontrol('style','edit','pos',[lft+15,btm,30,18],...
           'back','w','userdata',0,'string','1','horiz','right');

   ui(17) = uicontrol('style','text','pos',[lft+50,btm,10,17],...
           'horiz','left','string','f');
   ui(18) = uicontrol('style','edit','pos',[lft+60,btm,60,18],...
           'back','w','string',2','horiz','right');

   ui(20) = uicontrol('style','text','pos',[lft+125,btm,12,17],...
           'horiz','left','string','P');
   ui(21) = uicontrol('style','edit','pos',[lft+137,btm,30,18],...
           'back','w','string','0','horiz','right');

   btm = btm - 21;
   ui(6) = uicontrol('style','push','pos',[lft+17,btm,60,17],...
           'string','ADD','callback','dfftgui(2)');
   ui(7) = uicontrol('style','push','pos',[lft+87,btm,60,17],...
           'string','DELETE','callback','dfftedt(7)','enable','off');

   btm = btm - 5;
   uicontrol('style','frame','pos',[5,btm-54+27,175,49-23],...
             'back',grey,'fore',ltgrey);

   btm = btm - 22;
if ver4
   ui(23) = uicontrol('style','text','pos',[lft,btm,105,17],...
           'string','Sample Rate Hz','horiz','left','userdata',ui(2));
else
   ui(23) = uicontrol('style','text','pos',[lft,btm,105,17],...
           'string','Sampling Rate (Hz)','horiz','left','userdata',ui(2));
end

   ui(24) = uicontrol('style','edit','pos',[lft+110,btm,55,18],...
           'back','w','string','10','callback','dfftgui(3)','horiz','right');
   ui(25) = uicontrol('style','slider','pos',[lft+155,btm,10,17],...
           'userdata',ui(24),...
           'max',20,'min',5,'value',10,'vis','off');
   set(ui(24),'userdata',ui(25));

   ui(29) = uicontrol('style','text','pos',[lft,btm,100,17],...
           'string','Duration (sec)','horiz','left','vis','off');
   ui(30) = uicontrol('style','text','pos',[lft+105,btm,60,17],...
           'horiz','right','back',ltgrey,'vis','off');

   btm = btm - 5;
   uicontrol('style','frame','pos',[5,btm-121+22+25,175,117-22-25],...
             'back',grey,'fore',ltgrey);

   btm = btm - 27;

   ui(26) = uicontrol('style','text','pos',[lft,btm,100,17],...
           'string','N, [Padded N]','horiz','left');
   ui(27) = uicontrol('style','edit','pos',[lft+105,btm,60,18],...
         'back','w','string','20,128','callback','dfftgui(3)','horiz','right');
   ui(28) = uicontrol('style','slider','pos',[lft+155,btm,10,17],...
           'userdata',ui(27),...
           'max',20,'min',1,'value',10,'vis','off');
   set(ui(27),'userdata',ui(28));

   btm = btm - 22;
   ui(33) = uicontrol('style','text','pos',[lft,btm,65,17],...
           'string','Window','horiz','left');

ui(34) = uicontrol('style','popup','pos',[lft+70,btm-1,95,19],...
           'string',['None|Hamming|von Hann|Blackman|Kaiser|Chebyshev|',...
           'Harris'],...
           'back','w','callback','dfftgui(4)');

   btm = btm - 22; 
   ui(62) = uicontrol('style','text','pos',[lft,btm,100,17],...
           'horiz','right','string','Beta (0.3 to 3)');
   ui(63) = uicontrol('style','edit','pos',[lft+105,btm,60,18],...
           'back','w','string','2','callback','dfftgui(3)');
   ui(64) = uicontrol('style','text','pos',[lft,btm,100,17],...
           'horiz','right','string','Ripple (dB)');
   ui(65) = uicontrol('style','edit','pos',[lft+105,btm,60,18],...
           'back','w','string','60','callback','dfftgui(3)');
   ui(66) = uicontrol('style','text','pos',[lft,btm,100,17],...
           'horiz','right','string','Type (0 to 7)');
   ui(67) = uicontrol('style','edit','pos',[lft+105,btm,60,18],...
           'back','w','string','0','callback','dfftgui(3)');
   set(ui([62:67]),'vis','off');



   btm = btm - 5;
   uicontrol('style','frame','pos',[5,btm-49,175,47],...
             'back',grey,'fore',ltgrey);


   btm = btm - 24;
   ui(31) = uicontrol('style','text','pos',[lft,btm,75,17],...
           'string','FFT X-Axis','horiz','left');
   ui(32) = uicontrol('style','popup','pos',[lft+80,btm-1,85,19],...
           'string','Index|digital F|Analog f','back','w',...
           'callback','dfftplt');
   ui(51) = uicontrol('style','text','pos',[lft,btm,75,17],...
           'string','Axis Limits','horiz','left','vis','off');
   ui(52) = uicontrol('style','edit','pos',[lft+80,btm,85,18],'vis','off',...
           'back','w','string','0,10','callback','dfftgui(3)','horiz','right');

   btm = btm - 22;

   ui(49) = uicontrol('style','text','pos',[lft,btm,75,17],...
           'string','Magnitude','horiz','left');
   ui(50) = uicontrol('style','popup','pos',[lft+80,btm-1,85,19],...
           'string','Linear|dB','back','w','callback','dfftplt');
   uicontrol('style','text','pos',[lft,btm,80,17],...
           'string','Mag Y-Lim','horiz','left','vis','off');
   ui(4) = uicontrol('style','edit','pos',[lft+85,btm,80,18],...
           'back','w','string','0,1','callback','dfftgui(3)','vis','off');

   uicontrol('style','text','pos',[lft,btm,80,17],...
           'string','Phase Y-Lim','horiz','left','vis','off');

   ui(5) = uicontrol('style','edit','pos',[lft+85,btm,80,18],...
           'back','w','string','0,1','callback','dfftgui(3)','vis','off');

   btm = btm - 5;
   uicontrol('style','frame','pos',[5,btm-54+27,175,49-24],...
             'back',grey,'fore',ltgrey);

   btm = btm - 24;
   ui(59) = uicontrol('style','check','pos',[lft,btm,55,17],...
           'string','Auto','callback','dfftgui(5)');
   ui(60) = uicontrol('style','push','pos',[lft+60,btm,35,17],...
           'string','Plot','callback','dfftplt');

   ui(54) = uicontrol('style','check','pos',[lft+100,btm,67,18],...
           'string','Cursor','back','y','callback','dfftgui(7)');


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

   ui(55) = uicontrol('style','text','pos',[lef,bot,20,20],...
           'string','X ','horiz','right');
   ui(56) = uicontrol('style','text','pos',[lef+20,bot,60,20],...
           'string','','back','w');
   ui(57) = uicontrol('style','text','pos',[lef+85,bot,20,20],...
           'string','Y ','horiz','right');
   ui(58) = uicontrol('style','text','pos',[lef+105,bot,60,20],...
           'string','','back','w','userdata',0);
   set(ui(55:58),'vis','off');


   ui(35) = axes('units','pixel','pos',[210,260,390,140],'box','on',...
            'color','k','xcolor','w','ycolor','w','xgrid','on','ygrid','on');
   title('Portion of Sampled (g),  Analog (y-) and Reconstructed (m--) signal');
   xlabel('Time  [sec]');

   ui(36) = line('xdata',0,'ydata',0,'color','y');
   ui(37) = line('xdata',0,'ydata',0,'color','g');

   if ver4,
      ui(38) = line('xdata',0,'ydata',0,'color','g','linestyle','o');
   else
      ui(38) = line('xdata',0,'ydata',0,'color','g','linestyle','none',...
                    'marker','o');
   end
   ui(39) = line('xdata',0,'ydata',0,'color','m','linestyle','--');

   ui(40) = axes('units','pixel','pos',[210,60,175,140],'box','on',...
            'color','k','xcolor','w','ycolor','w','xgrid','on','ygrid','on');

   title('FFT magnitude (no window)');
   xlabel('FFT Index   [k]')
   ui(41) = line('xdata',0,'ydata',0,'color','c');
   if ver4,
      ui(42) = line('xdata',0,'ydata',0,'color','c','linestyle','o');
   else
      ui(42) = line('xdata',0,'ydata',0,'color','c','linestyle','none',...
                    'marker','o');
   end

   ui(43) = axes('units','pixel','pos',[425,60,175,140],'box','on',...
            'color','k','xcolor','w','ycolor','w','xgrid','on','ygrid','on');

   title('FFT magnitude (windowed)');
   xlabel('FFT Index   [k]')
   ui(44) = line('xdata',0,'ydata',0,'color','c');

   if ver4,
      ui(45) = line('xdata',0,'ydata',0,'color','c','linestyle','o');
   else

⌨️ 快捷键说明

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