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

📄 fsgui.m

📁 很多matlab的源代码
💻 M
📖 第 1 页 / 共 2 页
字号:
function fsgui(mode)
%FSGUI Graphical User Interface program for Fourier series of common signals.


% 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');
   filter_pop  = ui(4);
   window_pop  = ui(13);
   n_edt       = ui(6);
   cutoff_edt  = ui(9);
   beta_uis    = ui(14:15);
   ripple_uis  = ui(17:18);
   harris_uis  = ui(26:27);
   autoplot    = ui(21);
   plot_btn    = ui(22);
   axs         = ui(23);
   curs_btn = ui(48);
   curs_dsp = ui(44:47);
end

if mode == 0,
   grey = [0.5,0.5,0.5];
   ltgrey = grey*1.5;
   dkgrey = grey*0.5;
   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','Fourier Series Demo','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','Fourier Series Demo','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','fshlp');
   uim(3) = uimenu(uim(1),'label','Export Data','separator','on',...
                          'callback','fsgui(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','fsgui(17)');
   uim(7) = uimenu('label','   Zoom ON','separator','on',...
                          'callback','fsgui(18)');
   uim(8) = uimenu('label','   Zoom OFF','separator','on',...
                          'callback','fsgui(19)');

%%%%%%%%%%%


   lft = 10; btm = fig_h - 5;
   ui(1) = uicontrol('style','frame','pos',[5,btm-142+22-22,175,140-22+22],...
           'back',grey,'fore',ltgrey);

   btm = btm - 26;
   ui(2) = uicontrol('style','text','pos',[lft,btm,160,17],...
           'horiz','left','fore','c','string','Periodic Pulse Train');

   btm = btm - 22;
   ui(3) = uicontrol('style','text','pos',[lft,btm,40,17],...
           'string','Type','horiz','left');
   ui(4) = uicontrol('style','popup','pos',[lft+45,btm,120,20],...
           'string',['Rect pulse|Sawtooth|Tri pulse|Trapezoid|',...
                     'Cosine burst|Exponential'],...
           'back','w','callback','fsgui(1)');

   btm = btm - 22;
   ui(50) = uicontrol('style','text','pos',[lft,btm,100,17],...
           'horiz','right','string','Time Period');
   ui(51) = uicontrol('style','edit','pos',[lft+105,btm,60,18],...
           'back','w','string','1','callback','fsgui(3)');

   btm = btm - 22;
   ui(8) = uicontrol('style','text','pos',[lft,btm,100,17],...
           'horiz','right','string','Pulse Width');
   ui(9) = uicontrol('style','edit','pos',[lft+105,btm,60,18],...
           'back','w','string','0.5','callback','fsgui(3)');

   btm = btm - 22;
   ui(33) = uicontrol('style','text','pos',[lft,btm,100,17],...
           'horiz','right','string','Time Delay');
   ui(34) = uicontrol('style','edit','pos',[lft+105,btm,60,18],...
           'back','w','string','0','callback','fsgui(3)');

   btm = btm - 22;
   ui(35) = uicontrol('style','text','pos',[lft,btm,100,17],...
           'horiz','right','string','Flat Width','vis','off');
   ui(36) = uicontrol('style','edit','pos',[lft+105,btm,60,18],...
           'back','w','string','0.2','callback','fsgui(3)','vis','off');

   ui(37) = uicontrol('style','text','pos',[lft,btm,100,17],...
           'horiz','right','string','Exponent','vis','off');
   ui(38) = uicontrol('style','edit','pos',[lft+105,btm,60,18],...
           'back','w','string','-1','callback','fsgui(3)','vis','off');

   ui(39) = uicontrol('style','text','pos',[lft,btm,100,17],...
           'horiz','right','string','# of cycles','vis','off');
   ui(40) = uicontrol('style','edit','pos',[lft+105,btm,60,18],...
           'back','w','string','0.5','callback','fsgui(3)','vis','off');


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

   btm = btm - 35;
   ui(5) = uicontrol('style','text','pos',[lft,btm,100,17],...
           'horiz','right','string','# of Harmonics');
   ui(6) = uicontrol('style','edit','pos',[lft+105,btm,60,18],...
           'back','w','string','25','callback','fsgui(5)');


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

   btm = btm - 37;
   uicontrol('style','text','pos',[lft,btm-2,60,20],...
           'string','Counter');
   ui(42) = uicontrol('style','push','pos',[lft+65,btm,50,20],...
           'string','<<','callback','fsgui(4)');
   ui(43) = uicontrol('style','push','pos',[lft+115,btm,50,20],...
           'string','>>','callback','fsgui(8)');


   ui(7) = uicontrol('style','frame','pos',[5,btm-130+44,175,120-44],...
           'back',grey,'fore',ltgrey);


   btm = btm - 35;
   ui(11) = uicontrol('style','text','pos',[lft,btm,160,17],...
           'horiz','left','fore','c','string','Smoothing Window');

   btm = btm - 22;
   ui(12) = uicontrol('style','text','pos',[lft,btm,40,17],...
           'string','Type','horiz','left');

   ui(13) = uicontrol('style','popup','pos',[lft+45,btm,120,20],...
           'string',['None|Hamming|von Hann|Blackman|Kaiser|Chebyshev|',...
           'Harris'],...
           'back','w','callback','fsgui(2)');

   btm = btm - 22;
   ui(14) = uicontrol('style','text','pos',[lft,btm,100,17],...
           'horiz','right','string','Beta (0.3 to 3)');
   ui(15) = uicontrol('style','edit','pos',[lft+105,btm,50,18],...
           'back','w','string','2','callback','fsgui(3)','userdata',0);
%   ui(16) = uicontrol('style','slider','pos',[lft+155,btm,10,17],...
%           'min',0,'value',2,'max',8,'userdata',ui(15));
%   set(ui(15),'userdata',ui(16));
   set(ui(14:15),'vis','off');

   ui(17) = uicontrol('style','text','pos',[lft,btm,100,17],...
           'horiz','right','string','Ripple (dB)');
   ui(18) = uicontrol('style','edit','pos',[lft+105,btm,50,18],...
           'back','w','string','60','callback','fsgui(3)');
%   ui(19) = uicontrol('style','slider','pos',[lft+155,btm,10,17],...
%           'min',55,'value',60,'max',65,'userdata',ui(18));
%   set(ui(18),'userdata',ui(19));
   set(ui(17:18),'vis','off');

   ui(26) = uicontrol('style','text','pos',[lft,btm,100,17],...
           'horiz','right','string','Type (0 to 7)');
   ui(27) = uicontrol('style','edit','pos',[lft+105,btm,50,18],...
           'back','w','string','0','callback','fsgui(3)');
%   ui(28) = uicontrol('style','slider','pos',[lft+155,btm,10,17],...
%           'min',0,'value',0,'max',7,'userdata',ui(27));
%   set(ui(27),'userdata',ui(28));
   set(ui(26:27),'vis','off');


   ui(20) = uicontrol('style','frame','pos',[5,btm-40,175,27],...
           'back',grey,'fore',ltgrey);

   btm = btm - 35;
   ui(21) = uicontrol('style','check','pos',[lft,btm,80,17],...
           'string','AutoPlot','callback','fsgui(5)',...
           'value',0);
   ui(22) = uicontrol('style','push','pos',[lft+95,btm-2,70,20],...
           'string','Plot','callback','fsplt');

   btm = btm -40+20;
   ui(30) = uicontrol('style','frame','pos',[5,btm-10-5,175,27],...
           'back',grey,'fore',ltgrey);

   btm = btm - 10;
   ui(31) = uicontrol('style','text','pos',[lft,btm,38,17],...
           'string','Show');
   ui(32) = uicontrol('style','popup','pos',[lft+40,btm,127,17],...
           'string','Linear','string',['Reconstruction|',...
'Unwindowed mag|Windowed mag|Phase Spectrum'],...
           'back','w','callback','fsplt'); %was fsgui(6)

   btm = btm -40+15;
   uicontrol('style','frame','pos',[5,btm-10-5,175,27],...
           'back',grey,'fore',ltgrey);

   btm = btm - 10;
   uicontrol('style','text','pos',[lft,btm,90,17],...
           'string','Convergence');
   ui(41) = uicontrol('style','text','pos',[lft+95,btm,70,17],...
           'string','1/k','back',ltgrey);

   btm = btm - 32;
   ui(48) = uicontrol('style','check','pos',[lft+95,btm,70,20],...
           'string','Cursor','back','y','callback','fsgui(6)');


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

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



   ui(23) = axes('units','pixel','pos',[210,50,390,350],'box','on',...
            'xlim',[0,1],'color','k','xgrid','on','ygrid','on');
   title('Magnitude  Spectrum');
   xlabel('Digital Frequency [F]');
   ui(24) = line('xdata',0,'ydata',0,'color','y');
if ver4
   ui(25) = line('xdata',0,'ydata',0,'color','g');
else
   ui(25) = line('xdata',0,'ydata',0,'color','g','linestyle','none',...
                 'marker','o');
end

⌨️ 快捷键说明

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