📄 ctcongui.m
字号:
function ctcongui(mode)
%CTCONGUI Graphical User Interface program for continuous convolution
% 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');
action_pop = ui(13);
n_edt = ui(4);
xn_edt = ui(6);
h_edt = ui(10);
hn_edt = ui(12);
sig_axs = ui(23);
opr_axs = ui(45);
top_axs = ui(26);
bot_axs = ui(28);
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','Continuous Convolution','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','Continuous Convolution','numbertitle','off',...
'resize','off','vis','off','interruptible',int_str,...
'color',dkgrey,'defaultaxesfontsize',8,...
'defaultuicontrolback',[0.5,0.5,0.5],...
'defaulttextfontsize',8);
end
%%% OPTIONS: Change NAME to gui name e.g. bode %%%%%%%%%%%%%%%
uim(1) = uimenu('label','OPTIONS');
uim(2) = uimenu(uim(1),'label','Help and Info','callback','ctconhlp');
uim(3) = uimenu(uim(1),'label','Export Data','separator','on',...
'callback','ctcongui(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','RESIZE','callback','ctcongui(20)');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
lft = 10; btm = fig_h - 5;
ui(1) = uicontrol('style','frame','pos',[5,btm-142-40,175,75+100],...
'back',grey,'fore',ltgrey);
btm = btm - 52+20;
ui(2) = uicontrol('style','text','pos',[lft,btm,160,17],...
'horiz','left','fore','c','string','Signal x(t)');
btm = btm - 22;
ui(3) = uicontrol('style','text','pos',[lft,btm,55,17],...
'string','Range t','horiz','left');
ui(4) = uicontrol('style','edit','pos',[lft+60,btm,105,18],...
'back','w','string','-2,2');
btm = btm - 22;
ui(5) = uicontrol('style','text','pos',[lft,btm,30,17],'string','x(t)');
ui(6) = uicontrol('style','edit','pos',[lft+35,btm,130,18],...
'back','w','string','tri(t/2)');
btm = btm - 30;
ui(8) = uicontrol('style','text','pos',[lft,btm,160,17],...
'horiz','left','fore','c','string','Signal h(t)','userdata',[]);
btm = btm - 22;
ui(9) = uicontrol('style','text','pos',[lft,btm,55,17],...
'horiz','right','string','Range t');
ui(10) = uicontrol('style','edit','pos',[lft+60,btm,105,18],...
'back','w','string','-1,1');
btm = btm - 22;
ui(11) = uicontrol('style','text','pos',[lft,btm,30,17],'string','h(t)');
ui(12) = uicontrol('style','edit','pos',[lft+35,btm,130,18],...
'back','w','string','tri(t)');
btm = btm -25;
ui(7) = uicontrol('style','push','pos',[lft+55,btm,70,17],...
'string','Accept','callback','ctcongui(2)','userdata',[]);
ui(36) = uicontrol('style','frame','pos',[5,btm-35,175,25],...
'back',grey,'fore',ltgrey);
btm = btm - 32;
ui(37) = uicontrol('style','text','pos',[lft,btm,70,17],'string','Time Step');
ui(38) = uicontrol('style','edit','pos',[lft+75,btm,90,18],...
'back','w','string','0.01','callback','ctcongui(2)');
btm = btm - 35;
ui(18) = uicontrol('style','text','pos',[lft,btm,50,17],...
'back','r','string','Action');
ui(13) = uicontrol('style','popup','pos',[lft+55,btm,115,20],...
'string',['Edit Signals|Convolution Yxh|Convolution Yhx|',...
'Correlation Rxh|Correlation Rhx'],...
'back','w','callback','ctcongui(1)');
btm = btm - 30;
ui(14) = uicontrol('style','frame','pos',[5,btm-142+5+20+30,175,60],...
'back',grey,'fore',ltgrey,'vis','off');
btm = btm - 40-10;
if ver4
ui(15) = uicontrol('style','text','pos',[lft,btm,160,17],'back',grey,...
'fore','b','string','TO ANIMATE RESULTS','vis','off');
else
ui(15) = uicontrol('style','text','pos',[lft,btm,160,17],'back',grey,...
'fore','b','string','TO ANIMATE THE RESULTS','vis','off');
end
btm = btm - 17;
if ver4
ui(16) = uicontrol('style','text','pos',[lft,btm,160,17],'back',grey,...
'fore','c','string','Click on Shifted Signal','vis','off');
else
ui(16) = uicontrol('style','text','pos',[lft,btm,160,17],'back',grey,...
'fore','c','string','Click on Shifted (Red) Signal','vis','off');
end
btm = btm - 17;
ui(17) = uicontrol('style','text','pos',[lft,btm,160,17],'back',grey,...
'fore','c','string','In Bottom Plot and Drag','vis','off');
btm = btm - 30;
ui(20) = uicontrol('style','frame','pos',[5,btm-142+130,175,30],...
'back',grey,'fore',ltgrey,'vis','off');
btm = btm - 7;
ui(21) = uicontrol('style','text','pos',[lft,btm,165,18],...
'back','w','string','','vis','off');
ui(26) = axes('units','pixel','pos',[210,255,390,160],'box','on',...
'xgrid','on','ygrid','on','color','k');
if ver4
title('Signal x(t)');
xlabel('Time t');
else
title('Signal x({\itt})');
xlabel('Time {\itt}');
end
ui(27) = line('xdata',0,'ydata',0,'color','y');
ui(28) = axes('units','pixel','pos',[210,40,390,160],'box','on',...
'xgrid','on','ygrid','on','color','k');
if ver4
title('Signal h(t)');
xlabel('Time t');
else
title('Signal h({\itt})');
xlabel('Time {\itt}');
end
ui(29) = line('xdata',0,'ydata',0,'color','r');
ui(23) = axes('units','pixel','pos',[-600,255,390,160],'box','on',...
'xgrid','on','ygrid','on','color','k');
title('Signal x');
if ver4
xlabel('Dummy Variable lambda');
else
xlabel('Dummy Variable {\lambda}');
end
ui(24) = line('xdata',0,'ydata',0,'color','y');
ui(25) = line('xdata',0,'ydata',0,'color','r');
set(ui(23),'userdata',ui(24:25));
set(ui(2),'userdata',ui(23));
ui(45) = axes('units','pixel','pos',[-600,40,390,160],'box','on',...
'xgrid','on','ygrid','on','color','k');
title('Signal y');
xlabel('Time t');
if ver4,ers='xor';else,ers='xor';end
ui(30)=line('xdata',[],'ydata',[],'color','y','erase','none','linewidth',2);
ui(31)=line('xdata',0,'ydata',0,'color','r','erase',ers,'linewidth',2);
if ver4
ui(32)=line('xdata',0,'ydata',0,'color','g','erase',ers,...
'linestyle','.','markersize',20);
else
ui(32)=line('xdata',0,'ydata',0,'color','g','erase',ers,...
'linestyle','none','marker','.','markersize',20);
end
ui(33)=line('color','m','erase',ers,'xdata',[],'ydata',[],'linewidth',2);
if ver4
ui(34)=line('xdata',0,'ydata',0,'color','m','erase',ers,...
'linestyle','.','markersize',20);
else
ui(34)=line('xdata',0,'ydata',0,'color','m','erase',ers,...
'linestyle','none','marker','.','markersize',20);
end
%ui(35)=line('color','c','erase','xor','xdata',[],'ydata',[],'linewidth',3);
ui(35)=patch(0,0,'c');
set(ui(35),'erase','xor');
set(ui(45),'userdata',ui(30:35));
set(ui(3),'userdata',ui(45));
set(f,'userdata',ui);
ctcongui(1);
drawnow;
set(f,'vis','on');
elseif mode == 1, % signal popup
action = get(action_pop,'value');
if action==1
set(ui(7),'userdata',[]);
set(ui(8),'userdata',[]);
set(ui([4,6,7,10,12]),'enable','on');
set(f,'windowbuttonmotionfcn','');
set(top_axs,'pos',[210 260 390 160]);
set(bot_axs,'pos',[210 40 390 160]);
set(sig_axs,'pos',[-600 260 390 160]);
set(opr_axs,'pos',[-600 40 390 160]);
ctcongui(2);
else
ctcongui(2);
end
elseif mode == 2, % edit
% obtain time step
t_st = get(ui(38),'string');
if isempty(t_st),
errordlg('No Value entered for time step.','Input Error');
return;
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -