Azzera filtri
Azzera filtri

Reset to original view for UIAxes control in AppDesigner programmatically

22 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

Avni Agrawal
Avni Agrawal il 25 Lug 2024 alle 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!

Più risposte (0)

Categorie

Scopri di più su Startup and Shutdown in Help Center e File Exchange

Prodotti


Release

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by