Hold plot toggle using app designer

25 vues (au cours des 30 derniers jours)
Donny Wong
Donny Wong le 9 Nov 2018
Commenté : Donny Wong le 10 Nov 2018
I am using the app designer to create a UI with a graph (app.Graph), a hold switch (app.HoldGraphSwitch) and a calculate button (app.CalculateButton).
I want it so when the hold switch is set to 'on', then the graph holds the previous plots on the graph but if set to 'off, then the graph clears previous plots.
I have tried the following but does not clear the graph:
function CalculateButtonPushed(app, event)
if app.HoldGraphSwitch.Value==0
hold(app.Graph, 'off')
else
hold(app.Graph, 'on')
end
plot(app.Graph,x,y)
end
Any solutions would be appriciated :) Thanks!

Réponse acceptée

Cris LaPierre
Cris LaPierre le 9 Nov 2018
The hold command only tells it how to treat the next plot. Clearing your axes is a different process. There are numerous ways to do it, so it depends what functionality you want.
Consider using cla(app.UIAxes). You can read more about cla here .
Other options include clearing the line object's XData , YData, ... properties.
  1 commentaire
Donny Wong
Donny Wong le 10 Nov 2018
Thank you, that seems to have done the trick.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by