How to i reset/clear an figure in app designer?

772 views (last 30 days)
I tried to write
app.UIAxes.cla;
or
cla(app.UIAxes)
but it doesn't do the job.
Yes it clears the figure, but when I replot something, in the same figure, the old data is still there.
How can I remove this previous data/plots?
  3 Comments
Eric Sargent
Eric Sargent on 9 Dec 2020
You also need to specify what kind of hold you want.
Your code is:
hold(app.UIAxes);
Which toggles hold between "on" and "off" and thus could very well be contributing your observed behavior.
You need to specify "on" or "off" as follows:
hold(app.UIAxes,"on");
or
hold(app.UIAxes,"off");

Sign in to comment.

Accepted Answer

Fabian Winkler
Fabian Winkler on 27 May 2020
Found the solution.
cla(app.UIAxes)
worked for me.
Befor I got an error: "Reference to a cleared variable app". This was because of a
clear all
. Without it, everything is fine.

More Answers (1)

Hadi Mahmodi
Hadi Mahmodi on 20 Jun 2022
cla(app.UIAxes, 'reset')
this worked for me. Matlab 2020a

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by