Filter löschen
Filter löschen

Reset to original view for UIAxes control in AppDesigner programmatically

22 Ansichten (letzte 30 Tage)
Hello,
I am trying to programmatically restore the zoom for original view for UIAxes compoinent in AppDesigner.
I'd like to achieve the same as clicking on the 'house' icon at the zoom controls.
Does anyone know how to do this?
--Han

Akzeptierte Antwort

Avni Agrawal
Avni Agrawal am 25 Jul. 2024 um 5:46
I understand that you are trying to reset the original view for a `UIAxes` control in App Designer programmatically. There are two different ways to reset the `UIAxes` in App Designer:
Method 1: Using Auto Limits
When no limit is set, the default behavior is to set the limit to `auto`.
% Button pushed function: Button
function ButtonPushed(app, event)
xlim(app.UIAxes, "auto");
ylim(app.UIAxes, "auto");
end
Method 2: Reset to Original Limits
Reset the limit values based on what they were originally set to when the axis was initialized.
% Store original limits in the startup function
function startupFcn(app)
plot(app.UIAxes, peaks);
app.originalXLim = app.UIAxes.XLim;
app.originalYLim = app.UIAxes.YLim;
end
% Button pushed function: Button
function ButtonPushed(app, event)
xlim(app.UIAxes, app.originalXLim);
ylim(app.UIAxes, app.originalYLim);
end
For a better understanding, please refer to this documentation: https://www.mathworks.com/help/matlab/creating_plots/change-axis-limits-of-graph.html
I hope this helps!
  1 Kommentar
Han Geerligs
Han Geerligs am 25 Jul. 2024 um 6:18
Thanks for your response.
I was in fact looking for the solution "Using Auto Limits".
--Han

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Produkte


Version

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by