📄 fsgui.m
字号:
ui(43) = line('xdata',0,'ydata',0,'color','y','erase','none');
ui(53) = line('xdata',0,'ydata',0,'color','m','erase','back');
ui(54) = line('xdata',0,'ydata',0,'color','m','erase','none');
set(f,'userdata',ui);
set(ui(7),'userdata',ui(23));
fsplt;
drawnow;
set(f,'vis','on');
elseif mode == 1, % signal popup
signal_type = get(filter_pop,'value');
if signal_type == 4
set(ui(37:40),'vis','off');
set([ui(35),ui(36)],'vis','on');
elseif signal_type == 5
set(ui(35:38),'vis','off');
set([ui(39),ui(40)],'vis','on');
elseif signal_type == 6
set(ui(35:36),'vis','off');
set(ui(39:40),'vis','off');
set([ui(37),ui(38)],'vis','on');
else
set(ui(35:40),'vis','off');
end
if get(autoplot,'value'), fsplt; end
elseif mode == 2, % window popup
window_type = get(window_pop,'value');
if any(window_type == [(1:4)]),
set([beta_uis,ripple_uis,harris_uis],'vis','off');
elseif window_type == 5, %Kaiser
set(beta_uis,'vis','on');
set(ripple_uis,'vis','off');
set(harris_uis,'vis','off');
elseif window_type == 6, %Cheby
set(ripple_uis,'vis','on');
set(beta_uis,'vis','off');
set(harris_uis,'vis','off');
elseif window_type == 7, % Harris
set(ripple_uis,'vis','off');
set(beta_uis,'vis','off');
set(harris_uis,'vis','on');
end
if get(autoplot,'value'), fsplt; end
elseif mode == 3, % edit fields
window_type = get(window_pop,'value');
edt = gco;
if any(edt == [harris_uis(2),...
beta_uis(2),ripple_uis(2)]),
% sld = get(edt,'userdata');
% sld_val = get(sld,'value');
edt_val = eval(['[',get(edt,'string'),']'],'[]');
if ~length(edt_val),
errordlg('You must enter a VALID number.','Input Error');
% set(edt,'string',num2str(sld_val));
return;
elseif edt == ripple_uis(2), % inspect cheb ripple
if edt_val <= 0,
errordlg('Ripple must be a positive value.','Input Error');
% set(edt,'string',num2str(sld_val));
return;
end
elseif edt == harris_uis(2), % inspect harris type
if edt_val < 0 | edt_val > 7 | rem(edt_val,1)~=0,
errordlg('Enter integer type form 0 to 7.','Input Error');
% set(edt,'string',int2str(sld_val));
return;
% else
% edt_val = floor(edt_val);
end
end
% set(edt,'string',num2str(edt_val));
% set(sld,'value',edt_val);
% if edt ~= harris_uis(2),
% set(sld,'min',edt_val-5,'max',edt_val+5);
% end
end
if get(autoplot,'value'), fsplt; end
elseif mode == 4,
k_str=get(ui(6),'string');
if isempty(k_str),
k_val=0;
else
k_val= eval(['[',k_str,']'],[]);
if isempty(k_val),
errordlg('Matlab syntax error.','Input Error');
return
end
if rem(k_val,1)|k_val<0,
errordlg('# of harmonics must be an integer.','Input Error');
return
end
end
k_val=k_val-1;if k_val<0,k_val=0;end
k_str=int2str(k_val);
set(ui(6),'string',k_str);
fsplt;
elseif mode == 8,
k_str=get(ui(6),'string');
if isempty(k_str),
k_val=0;
else
k_val= eval(['[',k_str,']'],[]);
if isempty(k_val),
errordlg('Matlab syntax error.','Input Error');
return
end
if rem(k_val,1)|k_val<0,
errordlg('# of harmonics must be an integer.','Input Error');
return
end
end
k_str=int2str(k_val+1);
set(ui(6),'string',k_str);
fsplt;
elseif mode == 5, % auto plot
if get(autoplot,'value'),
set(plot_btn,'enable','off');
fsplt;
else
set(plot_btn,'enable','on');
end
elseif mode == 6, % cursor
if get(curs_btn,'value')
set(curs_dsp,'vis','on');
set(f,'WindowButtonMotionFcn','fsgui(7)',...
'WindowButtonDownFcn','fsgui(7)');
else
set(f,'Pointer','arrow','WindowButtonMotionFcn','','WindowButtonDownFcn','')
set(curs_dsp,'vis','off')
set(curs_btn,'value',0),
end
elseif mode == 7, % 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
fsplt;
str1='Export original signal as';
str2='Export reconstructed signal as';
str3='Export windowed reconstruction as';
str4='Export time index as';
str5='Export unwindowed harmonic magnitude as';
str6='Export windowed harmonic magnitude as';
str7='Export harmonic phase as';
str8='Export harmonic index as';
str9='Export Fourier series coefficients (symbolic) as';
exp_str={str1,str2,str3,str4,str5,str6,str7,str8,str9};
exp_var={'xper','xrec','xwin','xtime','Mx','Mwx','Px','Nx','Xk'};
expect=inputdlg(exp_str,'Save Variables as',1,exp_var);
if ~isempty(expect)
xd=get(ui(44),'userdata');%%% FIX FOR UIs
hd=get(ui(45),'userdata');%%% FIX FOR UIs
xc=get(ui(46),'userdata');
if ~isempty(expect{1}),assignin('base',expect{1},xd(:,1));end
if ~isempty(expect{2}),assignin('base',expect{2},xd(:,2));end
if ~isempty(expect{3}),assignin('base',expect{3},xd(:,3));end
if ~isempty(expect{4}),assignin('base',expect{4},xd(:,4));end
if ~isempty(expect{5}),assignin('base',expect{5},hd(:,1));end
if ~isempty(expect{6}),assignin('base',expect{6},hd(:,2));end
if ~isempty(expect{7}),assignin('base',expect{7},hd(:,3));end
if ~isempty(expect{8}),assignin('base',expect{8},hd(:,4));end
if ~isempty(expect{9}),assignin('base',expect{9},xc);end
end
elseif mode == 16, % Axis Control Help
msgbox(['Turn Cursor off. Click in a plot window. ',...
' Then, come back and click on 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),fsgui(16);
else
set(curs_btn,'value',0);
fsgui(6); %%% REPLACE number BY CURSOR MODE
if any(cur_axs==ui([23])),%%%% CHANGE UI numbers
val=get(ui(32),'value');
if val==1,txt='Reconstruction';%%%% CHANGE UI numbers
elseif val==2,txt='Harmonic magnitude';%%%% CHANGE UI numbers
elseif val==3,txt='Harmonic phase';%%%% CHANGE UI numbers
end
axlimdlg(txt,[1 1]); %[1 1]=auto +linear/log, [1 0]=auto, no linear/log
else
fsgui(16);
end
end
elseif mode == 18, % zoom on
set(curs_btn,'value',0);
fsgui(6); % Use CURSOR MODE
if get(ui(15),'userdata')==0 %%Change ui(15) to whatever
zoom on
set(ui(15),'userdata',1);
else
msgbox('Zoom is already ON.','Zoom Info','help')
end
elseif mode == 19, % zoom off
set(curs_btn,'value',0);
fsgui(6); % Use CURSOR MODE
if get(ui(15),'userdata')==1
%%%%%Insert old zoom off here
set(f,'currentaxes',ui(23));
zoom out,zoom reset,zoom off
set(ui(15),'userdata',0);
else
msgbox('Zoom is already OFF.','Zoom Info','help')
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -