问题描述
我最近将最初在 GUIDE 中设计的应用程序转换为应用程序设计器。我没有编写原始代码,由于转换,我什至不知道如何搜索这个问题的答案。如果这已在其他地方提及,我深表歉意。
在我的应用中,我可以加载包含线性时间尺度信号数据的 txt 文件。使用该应用程序,我可以滚动到感兴趣的信号。然后,我使用回调函数设置“原点”或信号的来源,该函数在一致的时间范围内重新绘制信号。
这与旧工具的工作方式完全一样,非常棒。我可以处理信号,然后继续前进。问题是当我缩小,然后滚动以找到我感兴趣的下一个信号时。如果我完全双击绘图上的任何地方,绘图将再次缩放到原点位置,并具有由 setorigo_Callback 函数创建的一致时间刻度。此外,如果我找到其他感兴趣的信号并处理它们,包括在 x 轴上设置一个新的原点位置,如果我双击它,它将缩放到我指定的第一个原点位置。如果我设置了新的 origo 没有关系,当我第一次打开应用程序时,双击会将我发送到第一个 origo 进程的位置。
有人知道这里发生了什么吗?或者,我怎么能阻止它?我似乎无法清除有价值的原点,也无法抹去第一个原点集的情节记忆。请查看完整代码。 非常感谢!
Sample data: 1990.txt
Minute microsec cycles SPL_Pa kHz Bandwidth end kHz
14/5/2019 13:11 3220245 6 97 149 2 185
14/5/2019 13:11 4479150 11 16 55 5 83
14/5/2019 13:11 4479650 4 54 61 0 64
... and so on.
classdef cpodcalibrate_App < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
figure1 matlab.ui.figure
Untitled_1 matlab.ui.container.Menu
loaddata matlab.ui.container.Menu
loadmatdata matlab.ui.container.Menu
savedata matlab.ui.container.Menu
uitoolbar1 matlab.ui.container.Toolbar
uitoggletool1 matlab.ui.container.toolbar.Toggletool
uitoggletool2 matlab.ui.container.toolbar.Toggletool
uitoggletool3 matlab.ui.container.toolbar.Toggletool
removeechoes matlab.ui.control.Button
Addtotable matlab.ui.control.Button
podnumber matlab.ui.control.EditField
datatable matlab.ui.control.Table
Frequencyselect matlab.ui.control.ListBox
angleselect matlab.ui.control.ListBox
removefromtable matlab.ui.control.Button
setorigo matlab.ui.control.Button
divisionline matlab.ui.control.Button
edit2 matlab.ui.control.EditField
clickplot matlab.ui.control.UIAxes
thresholdplot matlab.ui.control.UIAxes
nixplot matlab.ui.control.UIAxes
end
methods (Access = private)
function updateplot(app,handles)
global data t
axes(handles.clickplot);
cla;
t=((data.datetime(:,4)*60+data.datetime(:,5))-(data.datetime(1,4)*60-data.datetime(1,5)))*60+data.rectime*1e-6;
plot(t,log10(data.nix),'.')
end
function resetInteractions(app,event)
% This function resets the states of the toggle tools that
% impact user interactions. It also resets the figure interactions.
% Find all tools to reset. Exclude the tool associated
% with the event.
interactivetools = [app.uitoggletool1,app.uitoggletool2,app.uitoggletool3];
interactivetools(event.source == interactivetools) = [];
% Set the state of the tools to 'off'.
[interactivetools.State] = deal('off');
% Set figure interactions to 'off'.
datacursormode(app.figure1,'off')
rotate3d(app.figure1,'off');
pan(app.figure1,'off');
zoom(app.figure1,'off');
end
% Update components that require runtime configuration
function addRuntimeConfigurations(app)
% Set component properties that require runtime configuration
app.datatable.BackgroundColor = [1 1 1;0.9608 0.9608 0.9608];
app.datatable.ColumnFormat = {[] [] [] [] [] [] [] [] []};
end
end
% Callbacks that handle component events
methods (Access = private)
% Code that executes after component creation
function cpodcalibrate_openingFcn(app,varargin)
% Add runtime required configuration - Added by Migration Tool
addRuntimeConfigurations(app);
% Create GUIDE-style callback args - Added by Migration Tool
[hObject,eventdata,handles] = convertToGUIDECallbackArguments(app); %#ok<ASglu>
% This function has no output args,see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to cpodcalibrate (see VaraRGIN)
% Choose default command line output for cpodcalibrate
handles.output = hObject;
% Update handles structure
guidata(hObject,handles);
end
% Button pushed function: Addtotable
function Addtotable_Callback(app,event)
% Create GUIDE-style callback args - Added by Migration Tool
[hObject,handles] = convertToGUIDECallbackArguments(app,event); %#ok<ASglu>
%add line to table
global threshold
axes(handles.nixplot)
regline=lsline;
for angle=1:4
y=get(regline(angle),'Ydata');
sensitivity(angle)=y(1);
end;
%keyboard
datastring=cell(1,9);
datastring(1)=num2cell(str2double(get(handles.podnumber,'string')));
for n=1:4
datastring(1+n)=num2cell(sensitivity(n));
datastring(5+n)=num2cell(threshold(n));
end
table=get(handles.datatable,'data');
%keyboard;
if size(table,1)==0
table=datastring;
else
table=[table;datastring];
end
set(handles.datatable,'data',table);
save('Calibration.mat','table');
end
% Button pushed function: divisionline
function divisionline_Callback(app,event); %#ok<ASglu>
% hObject handle to divisionline (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global divider
axes(handles.clickplot)
divider=gline;
end
% Menu selected function: loaddata
function loaddata_Callback(app,event); %#ok<ASglu>
%Load C-POD export data
global data clicks meannix newfilename
[filename,pathname] = uigetfile('*.txt');
raw=readtable([pathname filename]);
%If there is an extra column on the older text files,this will
%sort the columnns correctly.
if width(raw)>7
rr=1;
else
rr=0;
end
headers = raw.Properties.VariableNames;
%% Extract variables from file content
%removes last line in data,as often incomplete.
raw(end,:)=[];
data.datetime=datevec(datetime(raw.(1)));
set(handles.podnumber,'string',filename(1:4));
data.podid=str2double(filename(1:4));
data.recdate=char(raw.(1));
data.rectime=raw.(2+rr); %useconds after whole minute
data.cycles=raw.(3+rr); % cycles
data.nix=raw.(4+rr); % peak pressure,Nick-units
data.frq=raw.(5+rr); % Instantaneous frequency
data.bandwidth=raw.(6+rr); % Bandwidth,Nick-unit
data.endfrq=raw.(7+rr); % End-frequency in sweep
newfilename=[filename(1:end-4),'.mat'];
%keyboard
save(newfilename,'data');
updateplot(app,handles);
%initiate results arrays and clear plots
clicks=zeros(31,4); %number of clicks detected
meannix=zeros(31,4); %mean nix per block of 10 clicks
axes(handles.thresholdplot);
axes(handles.nixplot);
end
% Button pushed function: removeechoes
function removeechoes_Callback(app,event); %#ok<ASglu>
%Insert line and remove echoes
global data t origo clicks meannix divider threshold newfilename
axes(handles.clickplot)
x=get(divider,'Xdata');
y=get(divider,'Ydata');
alpha=(y(1)-y(2))/(x(1)-x(2));
beta=y(1)-alpha*x(1);
xlim=get(handles.clickplot,'xlim');
clicksinplotx=t(t>xlim(1)&t<xlim(2));
clicksinploty=data.nix(t>xlim(1)&t<xlim(2));
divideline=(clicksinplotx)*alpha+beta;
hold on
plot(clicksinplotx,divideline)
selectedclicksx=clicksinplotx(log10(clicksinploty)>divideline)-origo;
selectedclicksy=clicksinploty(log10(clicksinploty)>divideline);
%plot and analyze
angle=get(handles.angleselect,'value');
breaks=(0.0485:0.012:0.425)'; %Create breaks to separate blocks
for n=1:31
clicks(n,angle)=sum(selectedclicksx>breaks(n)&selectedclicksx<breaks(n+1));
meannix(n,angle)=mean(selectedclicksy(selectedclicksx>breaks(n)&selectedclicksx<breaks(n+1)));
end
axes(handles.thresholdplot);
att=0:30;
plot(att,clicks,'o-')
above=att(clicks(:,angle)>=5);
below=att(clicks(:,angle)<5);
%keyboard
if isempty(above) %all levels below threshold
threshold(angle)=NaN;
else
threshold(angle)=(above(end)+below(1))/2;
end
legend('0','90','180','270');
axes(handles.nixplot)
plot(att,20*log10(meannix),'.')
legend('0','270');
save(newfilename,'clicks','meannix','-append')
end
% Menu selected function: savedata
function savedata_Callback(app,event); %#ok<ASglu>
% Save spreadsheet to excelfile
table=get(handles.datatable,'data');
xlswrite('Calibration.xls',table);
save('Calibraton.mat','table');
end
% Button pushed function: setorigo
function setorigo_Callback(app,event); %#ok<ASglu>
% set t-axis zero at first sync pulse
global origo t data
axes(handles.clickplot)
[origo,y]=ginput(1);
cla;
plot(t,'.');
%Origo for click file without calib tones
%set(handles.clickplot,'xlim',[origo origo+0.425],'xtick',[origo+0.0005:0.012:origo+0.425]','xgrid','on');
set(handles.clickplot,[origo+0.0485:0.012:origo+0.425]','on');
hold on
plot(origo,y,'or');
end
% Clicked callback: uitoggletool3
function uitoggletool3_ClickedCallback(app,event)
% Reset the states of interactive tools and reset all figure
% interactions.
app.resetInteractions(event);
% Enable or disable pan based on the
% tool's current state.
state = app.uitoggletool3.State;
pan(app.figure1,char(state));
end
% Clicked callback: uitoggletool2
function uitoggletool2_ClickedCallback(app,event)
% Reset the states of interactive tools and reset all figure
% interactions.
app.resetInteractions(event);
% Enable or disable zoom-out based on the
% tool's current state.
state = app.uitoggletool2.State;
zoomModeObject = zoom(app.figure1);
if state
zoomModeObject.Direction = 'out';
zoomModeObject.Enable = 'on';
else
zoomModeObject.Enable = 'off';
end
end
% Clicked callback: uitoggletool1
function uitoggletool1_ClickedCallback(app,event)
% Reset the states of interactive tools and reset all figure
% interactions.
app.resetInteractions(event);
% Enable or disable zoom-in based on the
% tool's current state.
state = app.uitoggletool1.State;
zoomModeObject = zoom(app.figure1);
if state
zoomModeObject.Direction = 'in';
zoomModeObject.Enable = 'on';
else
zoomModeObject.Enable = 'off';
end
end
end
% Component initialization
methods (Access = private)
% Create UIfigure and components
function createComponents(app)
% Create figure1 and hide until all components are created
app.figure1 = uifigure('Visible','off');
app.figure1.Colormap = [0 0 0.5625;0 0 0.625;0 0 0.6875;0 0 0.75;0 0 0.8125;0 0 0.875;0 0 0.9375;0 0 1;0 0.0625 1;0 0.125 1;0 0.1875 1;0 0.25 1;0 0.3125 1;0 0.375 1;0 0.4375 1;0 0.5 1;0 0.5625 1;0 0.625 1;0 0.6875 1;0 0.75 1;0 0.8125 1;0 0.875 1;0 0.9375 1;0 1 1;0.0625 1 1;0.125 1 0.9375;0.1875 1 0.875;0.25 1 0.8125;0.3125 1 0.75;0.375 1 0.6875;0.4375 1 0.625;0.5 1 0.5625;0.5625 1 0.5;0.625 1 0.4375;0.6875 1 0.375;0.75 1 0.3125;0.8125 1 0.25;0.875 1 0.1875;0.9375 1 0.125;1 1 0.0625;1 1 0;1 0.9375 0;1 0.875 0;1 0.8125 0;1 0.75 0;1 0.6875 0;1 0.625 0;1 0.5625 0;1 0.5 0;1 0.4375 0;1 0.375 0;1 0.3125 0;1 0.25 0;1 0.1875 0;1 0.125 0;1 0.0625 0;1 0 0;0.9375 0 0;0.875 0 0;0.8125 0 0;0.75 0 0;0.6875 0 0;0.625 0 0;0.5625 0 0];
app.figure1.Position = [520 157 1142 644];
app.figure1.Name = 'cpodcalibrate';
app.figure1.Resize = 'off';
app.figure1.HandleVisibility = 'on';
app.figure1.Tag = 'figure1';
% Create Untitled_1
app.Untitled_1 = uimenu(app.figure1);
app.Untitled_1.Text = 'File';
app.Untitled_1.Tag = 'Untitled_1';
% Create loaddata
app.loaddata = uimenu(app.Untitled_1);
app.loaddata.MenuSelectedFcn = createCallbackFcn(app,@loaddata_Callback,true);
app.loaddata.Text = 'Open CPOD file';
app.loaddata.Tag = 'loaddata';
% Create loadmatdata
app.loadmatdata = uimenu(app.Untitled_1);
app.loadmatdata.Text = 'Open mat-file';
app.loadmatdata.Tag = 'loadmatdata';
% Create savedata
app.savedata = uimenu(app.Untitled_1);
app.savedata.MenuSelectedFcn = createCallbackFcn(app,@savedata_Callback,true);
app.savedata.Text = 'save';
app.savedata.Tag = 'savedata';
% Create uitoolbar1
app.uitoolbar1 = uitoolbar(app.figure1);
app.uitoolbar1.Tag = 'uitoolbar1';
% Create uitoggletool1
app.uitoggletool1 = uitoggletool(app.uitoolbar1);
app.uitoggletool1.Tag = 'uitoggletool1';
app.uitoggletool1.Tooltip = 'Zoom In';
app.uitoggletool1.ClickedCallback = createCallbackFcn(app,@uitoggletool1_ClickedCallback,true);
app.uitoggletool1.Icon = 'uitoggletool1_image.png';
% Create uitoggletool2
app.uitoggletool2 = uitoggletool(app.uitoolbar1);
app.uitoggletool2.Tag = 'uitoggletool2';
app.uitoggletool2.Tooltip = 'Zoom Out';
app.uitoggletool2.ClickedCallback = createCallbackFcn(app,@uitoggletool2_ClickedCallback,true);
app.uitoggletool2.Icon = 'uitoggletool2_image.png';
% Create uitoggletool3
app.uitoggletool3 = uitoggletool(app.uitoolbar1);
app.uitoggletool3.Tag = 'uitoggletool3';
app.uitoggletool3.Tooltip = 'Pan';
app.uitoggletool3.ClickedCallback = createCallbackFcn(app,@uitoggletool3_ClickedCallback,true);
app.uitoggletool3.Icon = 'uitoggletool3_image.png';
% Create removeechoes
app.removeechoes = uibutton(app.figure1,'push');
app.removeechoes.ButtonPushedFcn = createCallbackFcn(app,@removeechoes_Callback,true);
app.removeechoes.Tag = 'removeechoes';
app.removeechoes.BackgroundColor = [0.925490196078431 0.913725490196078 0.847058823529412];
app.removeechoes.FontSize = 11;
app.removeechoes.Position = [250 605 94 22];
app.removeechoes.Text = 'Remove echoes';
% Create Addtotable
app.Addtotable = uibutton(app.figure1,'push');
app.Addtotable.ButtonPushedFcn = createCallbackFcn(app,@Addtotable_Callback,true);
app.Addtotable.Tag = 'Addtotable';
app.Addtotable.BackgroundColor = [0.925490196078431 0.913725490196078 0.847058823529412];
app.Addtotable.FontSize = 11;
app.Addtotable.Position = [970 344 69 22];
app.Addtotable.Text = 'Add';
% Create podnumber
app.podnumber = uieditfield(app.figure1,'text');
app.podnumber.Tag = 'podnumber';
app.podnumber.HorizontalAlignment = 'center';
app.podnumber.FontSize = 11;
app.podnumber.Position = [971 394 49 20];
app.podnumber.Value = '0';
% Create datatable
app.datatable = uitable(app.figure1);
app.datatable.ColumnName = {'POD'; 'Sens 0'; 'Sens 90'; 'Sens 180'; 'Sens 270'; 'Thr 0'; 'Thr 90'; 'Thr 180'; 'Thr 270'};
app.datatable.ColumnEditable = [false false false false false false false false false];
app.datatable.Tag = 'datatable';
app.datatable.FontSize = 11;
app.datatable.Position = [709 44 422 251];
% Create Frequencyselect
app.Frequencyselect = uilistBox(app.figure1);
app.Frequencyselect.Items = {'110 kHz','120 kHz','130 kHz','140 kHz'};
app.Frequencyselect.Tag = 'Frequencyselect';
app.Frequencyselect.FontSize = 11;
app.Frequencyselect.Position = [970 532 72 62];
app.Frequencyselect.Value = '130 kHz';
% Create angleselect
app.angleselect = uilistBox(app.figure1);
app.angleselect.Items = {'0 degrees','90 degrees','180 degrees','270 degrees'};
app.angleselect.Tag = 'angleselect';
app.angleselect.FontSize = 11;
app.angleselect.Position = [970 444 89 63];
app.angleselect.Value = '0 degrees';
% Create removefromtable
app.removefromtable = uibutton(app.figure1,'push');
app.removefromtable.Tag = 'removefromtable';
app.removefromtable.BackgroundColor = [0.925490196078431 0.913725490196078 0.847058823529412];
app.removefromtable.FontSize = 11;
app.removefromtable.Position = [1051 344 69 22];
app.removefromtable.Text = 'Remove';
% Create setorigo
app.setorigo = uibutton(app.figure1,'push');
app.setorigo.ButtonPushedFcn = createCallbackFcn(app,@setorigo_Callback,true);
app.setorigo.Tag = 'setorigo';
app.setorigo.BackgroundColor = [0.925490196078431 0.913725490196078 0.847058823529412];
app.setorigo.FontSize = 11;
app.setorigo.Position = [50 606 69 22];
app.setorigo.Text = 'Set origo';
% Create divisionline
app.divisionline = uibutton(app.figure1,'push');
app.divisionline.ButtonPushedFcn = createCallbackFcn(app,@divisionline_Callback,true);
app.divisionline.Tag = 'divisionline';
app.divisionline.BackgroundColor = [0.925490196078431 0.913725490196078 0.847058823529412];
app.divisionline.FontSize = 11;
app.divisionline.Position = [150 605 69 22];
app.divisionline.Text = 'Division Line';
% Create edit2
app.edit2 = uieditfield(app.figure1,'text');
app.edit2.Tag = 'edit2';
app.edit2.HorizontalAlignment = 'center';
app.edit2.FontSize = 11;
app.edit2.Position = [517 606 89 20];
app.edit2.Value = 'Edit Text';
% Create clickplot
app.clickplot = uiaxes(app.figure1);
app.clickplot.Colormap = [0 0 0.5625;0 0 0.625;0 0 0.6875;0 0 0.75;0 0 0.8125;0 0 0.875;0 0 0.9375;0 0 1;0 0.0625 1;0 0.125 1;0 0.1875 1;0 0.25 1;0 0.3125 1;0 0.375 1;0 0.4375 1;0 0.5 1;0 0.5625 1;0 0.625 1;0 0.6875 1;0 0.75 1;0 0.8125 1;0 0.875 1;0 0.9375 1;0 1 1;0.0625 1 1;0.125 1 0.9375;0.1875 1 0.875;0.25 1 0.8125;0.3125 1 0.75;0.375 1 0.6875;0.4375 1 0.625;0.5 1 0.5625;0.5625 1 0.5;0.625 1 0.4375;0.6875 1 0.375;0.75 1 0.3125;0.8125 1 0.25;0.875 1 0.1875;0.9375 1 0.125;1 1 0.0625;1 1 0;1 0.9375 0;1 0.875 0;1 0.8125 0;1 0.75 0;1 0.6875 0;1 0.625 0;1 0.5625 0;1 0.5 0;1 0.4375 0;1 0.375 0;1 0.3125 0;1 0.25 0;1 0.1875 0;1 0.125 0;1 0.0625 0;1 0 0;0.9375 0 0;0.875 0 0;0.8125 0 0;0.75 0 0;0.6875 0 0;0.625 0 0;0.5625 0 0];
app.clickplot.FontSize = 13;
app.clickplot.NextPlot = 'replace';
app.clickplot.Tag = 'clickplot';
app.clickplot.Position = [24 322 937 280];
% Create thresholdplot
app.thresholdplot = uiaxes(app.figure1);
app.thresholdplot.Colormap = [0 0 0.5625;0 0 0.625;0 0 0.6875;0 0 0.75;0 0 0.8125;0 0 0.875;0 0 0.9375;0 0 1;0 0.0625 1;0 0.125 1;0 0.1875 1;0 0.25 1;0 0.3125 1;0 0.375 1;0 0.4375 1;0 0.5 1;0 0.5625 1;0 0.625 1;0 0.6875 1;0 0.75 1;0 0.8125 1;0 0.875 1;0 0.9375 1;0 1 1;0.0625 1 1;0.125 1 0.9375;0.1875 1 0.875;0.25 1 0.8125;0.3125 1 0.75;0.375 1 0.6875;0.4375 1 0.625;0.5 1 0.5625;0.5625 1 0.5;0.625 1 0.4375;0.6875 1 0.375;0.75 1 0.3125;0.8125 1 0.25;0.875 1 0.1875;0.9375 1 0.125;1 1 0.0625;1 1 0;1 0.9375 0;1 0.875 0;1 0.8125 0;1 0.75 0;1 0.6875 0;1 0.625 0;1 0.5625 0;1 0.5 0;1 0.4375 0;1 0.375 0;1 0.3125 0;1 0.25 0;1 0.1875 0;1 0.125 0;1 0.0625 0;1 0 0;0.9375 0 0;0.875 0 0;0.8125 0 0;0.75 0 0;0.6875 0 0;0.625 0 0;0.5625 0 0];
app.thresholdplot.FontSize = 13;
app.thresholdplot.NextPlot = 'replace';
app.thresholdplot.Tag = 'thresholdplot';
app.thresholdplot.Position = [25 22 336 280];
% Create nixplot
app.nixplot = uiaxes(app.figure1);
app.nixplot.Colormap = [0 0 0.5625;0 0 0.625;0 0 0.6875;0 0 0.75;0 0 0.8125;0 0 0.875;0 0 0.9375;0 0 1;0 0.0625 1;0 0.125 1;0 0.1875 1;0 0.25 1;0 0.3125 1;0 0.375 1;0 0.4375 1;0 0.5 1;0 0.5625 1;0 0.625 1;0 0.6875 1;0 0.75 1;0 0.8125 1;0 0.875 1;0 0.9375 1;0 1 1;0.0625 1 1;0.125 1 0.9375;0.1875 1 0.875;0.25 1 0.8125;0.3125 1 0.75;0.375 1 0.6875;0.4375 1 0.625;0.5 1 0.5625;0.5625 1 0.5;0.625 1 0.4375;0.6875 1 0.375;0.75 1 0.3125;0.8125 1 0.25;0.875 1 0.1875;0.9375 1 0.125;1 1 0.0625;1 1 0;1 0.9375 0;1 0.875 0;1 0.8125 0;1 0.75 0;1 0.6875 0;1 0.625 0;1 0.5625 0;1 0.5 0;1 0.4375 0;1 0.375 0;1 0.3125 0;1 0.25 0;1 0.1875 0;1 0.125 0;1 0.0625 0;1 0 0;0.9375 0 0;0.875 0 0;0.8125 0 0;0.75 0 0;0.6875 0 0;0.625 0 0;0.5625 0 0];
app.nixplot.FontSize = 13;
app.nixplot.NextPlot = 'replace';
app.nixplot.Tag = 'nixplot';
app.nixplot.Position = [375 22 336 280];
% Show the figure after all components are created
app.figure1.Visible = 'on';
end
end
% App creation and deletion
methods (Access = public)
% Construct app
function app = cpodcalibrate_App(varargin)
runningApp = getRunningApp(app);
% Check for running singleton app
if isempty(runningApp)
% Create UIfigure and components
createComponents(app)
% Register the app with App Designer
registerapp(app,app.figure1)
% Execute the startup function
runStartupFcn(app,@(app)cpodcalibrate_openingFcn(app,varargin{:}))
else
% Focus the running singleton app
figure(runningApp.figure1)
app = runningApp;
end
if nargout == 0
clear app
end
end
% Code that executes before app deletion
function delete(app)
% Delete UIfigure when app is deleted
delete(app.figure1)
end
end
end
解决方法
因此,从@Hoki 那里得到了一些建议,我制作了一个新按钮,可以调整轴的 xlim 和其他功能的大小。现在,根据我上次单击的是“set origo”还是“zoom to data”,双击将分别将我发送到每个范围。这意味着我至少可以摆脱设置 origo 确定的轴限制。我没有花时间摆脱自动 xgrid,因为老实说,我可以忍受它。
% Button pushed function: ZoomtoDataButton
function ZoomtoDataButtonPushed(app,event)
[hObject,eventdata,handles] = convertToGUIDECallbackArguments(app,event); %#ok<ASGLU>
axes(handles.clickplot)
cla;
updateplot(app,handles)
xlim('auto')
xticks('auto')
ylim('auto')
end