📄 diirgui.m
字号:
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
% axis('equal');
set(ui(85),'userdata',ui(86:88));
ui(90) = axes('units','pixel','pos',[220,35,160,160],'box','on',...
'color','k',...
'xgrid','on','ygrid','on');
title('Impulse Response h[n]');
xlabel('DT Index [n]');
ui(91) = line('xdata',0,'ydata',0,'color','m','erase','back');
%For drawing dt signals with markers
if ver4,
ui(92) = line('xdata',0,'ydata',0,'color','m','linestyle','o',...
'erase','back');
else
ui(92) = line('xdata',0,'ydata',0,'color','m','linestyle','none',...
'marker','o','erase','back');
end
set(ui(90),'userdata',ui([91,92]));
set(f,'userdata',ui);
set(ui(46),'value',1),
diirgui(7);
drawnow;
set(f,'vis','on');
set(ui(46),'value',0),
set(ui(47),'enable','on'),
elseif mode == 1, % filter
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'), diirplt; end
elseif any(mode == [2:3]), % method, and window popup
proto_type = get(proto_uis(2),'value');
method_type = get(method_uis(2),'value');
if get(autoplot,'value'), diirplt; 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;
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 any(edt == samp_uis(2)),
if edt_val <= 0,
errordlg('Sampling frequency must be positive.','Input Error');
return;
end
end
if get(autoplot,'value'), diirplt; 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');
diirplt;
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'),diirplt;end
end
end
elseif mode == 7, % autoplot
if get(autoplot,'value'),
set(plot_btn,'enable','off');
diirplt;
else
set(plot_btn,'enable','on');
end
elseif mode == 9, % cursor
if get(curs_btn,'value')
set(curs_dsp,'vis','on');
set(f,'WindowButtonMotionFcn','diirgui(10)');
else
set(f,'Pointer','arrow','WindowButtonMotionFcn','');
set(curs_dsp,'vis','off')
set(curs_btn,'value',0),
end
elseif mode == 10
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
%%%%%% PASTE AT END before last end statement %%%%%%%%%%%%%
elseif mode == 15, %Export data
diirplt;
mstr=get(ui(22),'string');mval=get(ui(22),'value');mstr=mstr(mval,:);%dB
str1='Export digital transfer function numerator as';
str2='Export digital transfer function denominator as';
str3=['Export ' mstr ' gain as'];
str4='Export phase (deg) as';
str5='Export analog frequency in Hz as';
str6='Export impulse response (symbolic) as';
exp_str={str1,str2,str3,str4,str5,str6};
exp_var={'Numiir','Deniir','gainiir','phaseiir','freqhz','hnresp'};
expect=inputdlg(exp_str,'Save Variables as',1,exp_var);
if ~isempty(expect)
na=get(ui(25),'userdata');%%% FIX FOR UIs
da=get(ui(26),'userdata');%%% FIX FOR UIs
fm=get(ui(27),'userdata');
fp=get(ui(28),'userdata');
ht=get(ui(29),'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);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),diirgui(16);
else
set(curs_btn,'value',0);
diirgui(9);
if any(cur_axs==ui([85,90,73,17])),
if cur_axs==ui(73),txt='Filter Magnitude';
elseif cur_axs==ui(17),txt='Filter Phase';
elseif cur_axs==ui(85),txt='Pole-Zero Plot';
elseif cur_axs==ui(90),txt='Impulse Response';
end
axlimdlg(txt,[1 1]); %[1 1]=auto +linear/log, [1 0]=auto, no linear/log
else
diirgui(16);
end
end
elseif mode == 18, % zoom on
set(curs_btn,'value',0);
diirgui(9); % Use CURSOR MODE
if get(ui(10),'userdata')==0 %%Change ui(15) to whatever
zoom on
set(ui(10),'userdata',1);
else
msgbox('Zoom is already ON.','Zoom Info','help')
end
elseif mode == 19, % zoom off
set(curs_btn,'value',0);
diirgui(9); % Use CURSOR MODE
if get(ui(10),'userdata')==1
%%%%%Insert old zoom off here
set(f,'currentaxes',ui(73));
zoom out,zoom reset,zoom off
set(f,'currentaxes',ui(17));
zoom out,zoom reset,zoom off
set(f,'currentaxes',ui(85));
zoom out,zoom reset,zoom off
set(f,'currentaxes',ui(90));
zoom out,zoom reset,zoom off
set(ui(10),'userdata',0);
else
msgbox('Zoom is already OFF.','Zoom Info','help')
end
elseif mode == 20, % mouse functionality
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),diirgui(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]);
if cur_axs==pz_axs
set(cur_axs,'pos',[210,35,380,380]);
else
set(cur_axs,'pos',[210,35,400,365]);
end
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
diirgui(16);
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -