📄 afdgui.m
字号:
else
ui(86) = line('xdata',0,'ydata',0,'color','c','linestyle','none',...
'marker','o','erase','back','markersize',8);
end
if ver4,
ui(87) = line('xdata',0,'ydata',0,'color','g','linestyle','x',...
'erase','back');
else
ui(87) = line('xdata',0,'ydata',0,'color','g','linestyle','none',...
'marker','x','erase','back','markersize',11);
end
set(ui(85),'userdata',ui(86:88));
% axis('equal');
ui(89) = axes('units','pixel','pos',[220,35,160,160],'box','on',...
'color','k','xgrid','on','ygrid','on');
title('Impulse Response h(t)');
xlabel('Time t');
ui(90) = line('xdata',0,'ydata',0,'color','m','erase','back');
set(ui(89),'userdata',ui(90));
set(f,'userdata',ui);
set(ui(46),'value',1),
afdgui(7);
drawnow;
set(f,'vis','on');
set(ui(46),'value',0),
set(ui(47),'enable','on'),
elseif mode == 1, % filter, method, and window popup
filter_type = get(filter_uis(2),'value');
edt_val = eval(['[',get(ui(11),'string'),']'],'[]');
if filter_type <3,val=2;else,val=4;end
len=length(edt_val);
if len~=val
set(autoplot,'value',0),
set(plot_btn,'enable','on');
end
if get(autoplot,'value'), afdplt; end
elseif any(mode == [2:3]), % filter, method, and window popup
proto_type = get(proto_uis(2),'value');
if get(autoplot,'value'), afdplt; end
elseif mode == 4, % edit fields
edt = gco;
edt_val = eval(['[',get(edt,'string'),']'],'[]');
if ~length(edt_val),
errordlg('You must enter a VALID number.','Input Error');
set(edt,'string',int2str(sld_val));
return;
set(edt,'string',num2str(edt_val,5));
set(sld,'value',edt_val,'min',edt_val-5,'max',edt_val+5);
end
if any(edt ==ui(11)),
filter_type = get(filter_uis(2),'value');
if filter_type <3,val=2;else,val=4;end
len=length(edt_val);
if len~=val
set(autoplot,'value',0),
set(plot_btn,'enable','on');
end
end
if get(autoplot,'value'), afdplt; end
elseif mode == 6, % auto design
edt = gco;
if edt ==autodes,
if get(autodes,'value'),
set(mandes,'value',0);
set(ui(67),'vis','on');
set(ui(68),'vis','off');
afdplt;
end
elseif edt ==mandes,
if get(mandes,'value'),
set(autodes,'value',0);
set(ui(67),'vis','off');
set(ui(68),'vis','on');
if get(autoplot,'value'),afdplt;end
end
end
elseif mode == 7, % autoplot
if get(autoplot,'value'),
set(plot_btn,'enable','off');
afdplt;
else
set(plot_btn,'enable','on');
end
elseif mode == 9, % cursor
if get(curs_btn,'value')
set(curs_dsp,'vis','on');
set(f,'WindowButtonMotionFcn','afdgui(10)');
else
set(f,'Pointer','arrow','WindowButtonMotionFcn','');
set(curs_dsp,'vis','off')
set(curs_btn,'value',0),
end
elseif mode == 10, % 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
elseif mode == 15, %Export data
afdplt;
fstr=get(ui(82),'string');fval=get(ui(82),'value');fstr=fstr(fval,:); %Hz
fll=get(ui(91),'string');lval=get(ui(91),'value');fll=fll(lval,:);%lin/log
mstr=get(ui(50),'string');mval=get(ui(50),'value');mstr=mstr(mval,:);%dB
str1='Export transfer function numerator as';
str2='Export transfer function denominator as';
str3=['Export ' mstr ' gain as'];
str4='Export phase (deg) as';
str5=['Export ' fll ' freq in ' fstr ' as'];
if lval==2,str5=['(Use semilogx to plot) ' str5];end
str6='Export step response (symbolic) as';
exp_str={str1,str2,str3,str4,str5,str6};
exp_var={'Numaf','Denaf','gainaf','phaseaf','freqaf','tresp'};
expect=inputdlg(exp_str,'Save Variables as',1,exp_var);
if ~isempty(expect)
na=get(ui(1),'userdata');%%% FIX FOR UIs
da=get(ui(2),'userdata');%%% FIX FOR UIs
fm=get(ui(10),'userdata');
fp=get(ui(11),'userdata');
ht=get(ui(12),'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(:,2));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),afdgui(16);
else
set(curs_btn,'value',0);
afdgui(9);
if any(cur_axs==ui([73,7,85,89])),
if cur_axs==ui(73),txt='Filter Gain';
elseif cur_axs==ui(7),txt='Filter Phase';
elseif cur_axs==ui(85),txt='Pole-Zero Plot';
elseif cur_axs==ui(89),txt='Impulse Response';
end
axlimdlg(txt,[1 1]); %[1 1]=auto +linear/log, [1 0]=auto, no linear/log
else
afdgui(16);
end
end
elseif mode == 18, % zoom on
set(curs_btn,'value',0);
afdgui(9); % Use CURSOR MODE
if get(ui(20),'userdata')==0 %%Change ui(15) to whatever
zoom on
set(ui(20),'userdata',1);
else
msgbox('Zoom is already ON.','Zoom Info','help')
end
elseif mode == 19, % zoom off
set(curs_btn,'value',0);
afdgui(9); % Use CURSOR MODE
if get(ui(20),'userdata')==1
%%%%%Insert old zoom off here
set(f,'currentaxes',ui(73));
zoom out,zoom reset,zoom off
set(f,'currentaxes',ui(7));
zoom out,zoom reset,zoom off
set(f,'currentaxes',ui(85));
zoom out,zoom reset,zoom off
set(f,'currentaxes',ui(89));
zoom out,zoom reset,zoom off
set(ui(20),'userdata',0);
%afdplt; % No need unless NAMEplt is modified
else
msgbox('Zoom is already OFF.','Zoom Info','help')
end
elseif mode == 20, % mouse functionality
% sel_type = get(f,'selectiontype');
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),afdgui(16);return,end
if any(cur_axs == [mag_axs,phs_axs,pz_axs,sig_axs]),
axes(cur_axs);
axs_pos = get(cur_axs,'pos');
if axs_pos(4) == 160, % need to maximize
set(mag_axs,'pos',[-600 35 160 160]);
set(phs_axs,'pos',[-600 35 160 160]);
set(pz_axs,'pos',[-600 246 160 160]);
set(sig_axs,'pos',[-600 246 160 160]);
set(cur_axs,'pos',[210,35,400,365]);
else % minimization
% set(mag_axs,'pos',[430 240 160 160]);
set(mag_axs,'pos',[430 246 160 160]);
set(phs_axs,'pos',[430 35 160 160]);
% set(pz_axs,'pos',[220 240 160 160]);
set(pz_axs,'pos',[220 246 160 160]);
set(sig_axs,'pos',[220 35 160 160]);
end
else
afdgui(16);
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -