📄 fvinit.m
字号:
'tag','magcheck',...
'value',ud.prefs.plots(1),...
'callback','filtview(''cb'',1)',...
'position',cb1_pos);
if ~isunix
label_ext = get(ud.ht.cb(1),'extent');
cb1_pos(3) = label_ext(3)+checkbox_width;
set(ud.ht.cb(1),'position', cb1_pos);
end
cb2_pos = [phf(1)+sz.fus phf(2)+sz.uh+sz.fus sz.bw sz.uh];
ud.ht.cb(2) = uicontrol(cb_props{:},...
'string','Phase',...
'tag','phasecheck',...
'value',ud.prefs.plots(2),...
'callback','filtview(''cb'',2)',...
'position',cb2_pos);
if ~isunix
label_ext = get(ud.ht.cb(2),'extent');
cb2_pos(3) = label_ext(3)+checkbox_width;
set(ud.ht.cb(2),'position', cb2_pos);
end
ud.ht.cb(3) = uicontrol(cb_props{:},...
'string','Group Delay',...
'tag','groupdelay',...
'value',ud.prefs.plots(3),...
'callback','filtview(''cb'',3)',...
'position',[pf(1)+2*sz.fus pf(2)+4*sz.fus+3*sz.uh sz.bw sz.uh]);
ud.ht.cb(4) = uicontrol(cb_props{:},...
'string','Zeros and Poles',...
'tag','polezero',...
'value',ud.prefs.plots(4),...
'callback','filtview(''cb'',4)',...
'position',[pf(1)+2*sz.fus pf(2)+3*sz.fus+2*sz.uh sz.bw sz.uh]);
ud.ht.cb(5) = uicontrol(cb_props{:},...
'string','Impulse Response',...
'tag','impresp',...
'value',ud.prefs.plots(5),...
'callback','filtview(''cb'',5)',...
'position',[pf(1)+2*sz.fus pf(2)+2*sz.fus+sz.uh sz.bw sz.uh]);
ud.ht.cb(6) = uicontrol(cb_props{:},...
'string','Step Response',...
'tag','stepresp',...
'value',ud.prefs.plots(6),...
'callback','filtview(''cb'',6)',...
'position',[pf(1)+2*sz.fus pf(2)+sz.fus sz.bw sz.uh]);
% ====================================================================
% Popups
pop_props = {'units','pixels',...
'style','popup','horizontalalignment','left'};
% Tweak position & size of popups: [horz_pos ver_pos width height]
switch computer
case 'MAC2'
popTweak = [0 -2 0 0];
case 'PCWIN'
popTweak = [0 0 0 0];
otherwise % UNIX
popTweak = [0 -2 0 0];
end
switch ud.prefs.magmode
case 'linear'
magpopvalue = 1;
case 'log'
magpopvalue = 2;
case 'decibels'
magpopvalue = 3;
end
ud.ht.magpop = uicontrol(pop_props{:},...
'string',{'linear'; 'log'; 'decibels'},...
'tag','maglist',...
'callback','filtview(''magpop'')',...
'value',magpopvalue,...
'position',[mf(1:2)+sz.fus+[indentPop 0] sz.bw-indentPop sz.uh]+popTweak);
switch ud.prefs.phasemode
case 'degrees'
phasepopvalue = 1;
case 'radians'
phasepopvalue = 2;
end
ud.ht.phasepop = uicontrol(pop_props{:},...
'string',{'degrees'; 'radians'},...
'tag','phaselist',...
'callback','filtview(''phasepop'')',...
'value',phasepopvalue,...
'position',[phf(1:2)+sz.fus+[indentPop 0] sz.bw-indentPop sz.uh]+popTweak);
switch ud.prefs.freqscale
case 'linear'
fscalevalue = 1;
case 'log'
fscalevalue = 2;
end
ud.ht.fscalepop = uicontrol(pop_props{:},...
'string',{'linear'; 'log'},...
'tag','freqscale',...
'callback','filtview(''fscalepop'')',...
'value',fscalevalue,...
'position',[fsf(1:2)+sz.fus+[indentPop 0] sz.bw-indentPop sz.uh]+popTweak);
ud.ht.frangepop = uicontrol(pop_props{:},...
'string',{'[0..Fs/2]'; '[0..Fs]'; '[-Fs/2..Fs/2]'},...
'tag','freqrange',...
'callback','filtview(''frangepop'')',...
'value',ud.prefs.freqrange,...
'position',[frf(1:2)+sz.fus+[indentPop 0] sz.bw-indentPop sz.uh]+popTweak);
% ====================================================================
% Create axes:
ax_props = {
'units','pixels',...
'box','on',...
'parent',fig};
% create axes:
for i=1:6
ud.ht.a(i) = axes(ax_props{:});
if i == 4 % Zero-Pole plot
w = linspace(0,2*pi,201);
zgrid = line(cos(w),sin(w), ...
'color',get(ud.ht.a(4),'xcolor'),...
'linestyle',':',...
'tag','unitcircle',...
'parent',ud.ht.a(4));
end
end
ud.titles = { 'Magnitude'
{ 'Phase (degrees)' 'Phase (radians)' }
'Group Delay'
'Zeros & Poles'
'Impulse Response'
'Step Response'};
ud.tags = { 'magaxes'
'phaseaxes'
'delayaxes'
'pzaxes'
'impaxes'
'stepaxes' };
ud.xlabels = { 'Frequency'
'Frequency'
'Frequency'
'Real'
'Time'
'Time' };
ud.ylabels = { ''
''
''
'Imaginary'
''
''};
th = get(ud.ht.a,'title');
set([th{[1 3:6]}],{'string'},ud.titles([1 3:6]))
switch ud.prefs.phasemode
case 'degrees'
set(th{2},'string',ud.titles{2}(1))
case 'radians'
set(th{2},'string',ud.titles{2}(2))
end
if fscalevalue == 2
set(ud.ht.a([1 2 3]),'xscale','log')
end
if magpopvalue == 2
set(ud.ht.a(1),'yscale','log')
end
set([th{:}],{'tag'},ud.tags)
set(ud.ht.a,{'tag'},ud.tags)
xh = get(ud.ht.a,'xlabel');
set([xh{:}],{'string'},ud.xlabels,{'tag'},ud.tags)
yh = get(ud.ht.a,'ylabel');
set([yh{:}],{'string'},ud.ylabels,{'tag'},ud.tags)
% ==================================================================
% Identify Main axes - axes where rulers are focused
% Let Magnitude plot be the default mainaxes
mainaxes = ud.ht.a(1);
set(mainaxes,'handlevisibility','callback');
ud.mainaxes = mainaxes;
% ====================================================================
% initialize lines to []
for i = 1:length(ud.filt)
ud.lines(i) = filtview('emptyLinesStruct');
end
% ====================================================================
% Save userdata structure
set(fig,'userdata',ud)
% ====================================================================
% now add toolbar for filter viewer
btnlist = { 'mousezoom' 'zoomout' 'help'}';
tb_callbackstr = {
'sbswitch(''fvzoom'',''mousezoom'')'
'sbswitch(''fvzoom'',''zoomout'')'
'sbswitch(''filtview'',''help'')' };
zoombar('fig',fig,'btnlist',btnlist,'callbacks',tb_callbackstr,...
'left_width',ud.resize.leftwidth,...
'right_width',sptlegend('width',fig)+2*ud.sz.lbs);
set(fig,'resizefcn',...
appstr(get(fig,'resizefcn'),'sbswitch(''fvresize'')'))
set(fig,'windowbuttonmotionfcn',...
['sbswitch(''fvmotion'',' num2str(ud.toolnum) ')'])
set(fig,'HandleVisibility','callback')
% ====================================================================
% create legend - changes userdata
sptlegend(fig,'filtview(''changefocus'')','filtview',1)
ud = get(fig,'userdata');
% ====================================================================
% Do the plots - changes userdata
filtview('plots',ud.prefs.plots)
ud = get(fig,'userdata');
% ====================================================================
% display the rulers on the default plot (magnitude);
if ud.prefs.tool.ruler
plotPopVal = 1; % mag plot is default
realFilterFlag = (isreal(ud.filt(ud.focusIndex).tf.num) &...
isreal(ud.filt(ud.focusIndex).tf.den));
ud.prefs.plottitles = filtview('plotTitles',realFilterFlag);
set(fig,'userdata',ud)
popupCallback = 'filtview(''rulerpopup'')';
ruler('init',fig,ud.prefs.plottitles,plotPopVal,popupCallback,...
ud.ht.a);
ud = get(fig,'userdata');
end
ud.focusline = ud.lines(ud.focusIndex).mag; % mag plot is default
set(fig,'userdata',ud)
% ====================================================================
% Initialize legend; set color and line style of all filters
ud = get(fig,'userdata');
for i = 1:length(ud.filt)
if isempty(ud.filt(i).lineinfo)
% assign line color and style to each filter
[ud.filt(i).lineinfo,ud.colorCount] = ...
nextcolor(ud.colororder,ud.linestyleorder,ud.colorCount);
% poke back into SPTool
sptool('import',ud.filt(i))
end
% Set line color & style for the rest of the lines for each filter
handleCell = struct2cell(ud.lines(i));
h = [handleCell{:}];
set(h,'color',ud.filt(i).lineinfo.color, ...
'linestyle',ud.filt(i).lineinfo.linestyle)
end
set(fig,'userdata',ud)
sptlegend('setstring',{ud.filt.label},{},fig,0)
sptlegend('setvalue',ud.focusline,ud.focusIndex,1,fig)
set(ud.legend.legendline,'linestyle', ...
ud.filt(ud.focusIndex).lineinfo.linestyle)
% ====================================================================
% position axes:
fvresize(1,fig)
% set ud.limits of 2 visible plots (the default plots, phase and mag)
ud = get(fig,'userdata');
ud = filtview('setudlimits',ud,ud.ht.a,[1 2]);
set(fig,'userdata',ud)
if ud.prefs.tool.ruler
ruler('newlimits',fig)
ruler('newsig',fig)
ruler('showlines',fig)
end
set(fig,'visible','on')
set(0,'showhiddenhandles',save_shh)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -