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

568 ビュー (過去 30 日間)
Happy PhD
Happy PhD 2020 年 4 月 29 日
回答済み: Hadi Mahmodi 2022 年 6 月 20 日
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 件のコメント
Fabian Winkler
Fabian Winkler 2020 年 5 月 27 日
I have the same problem.
This is how I plot the data in the first button pushed function
hold(app.UIAxes);
plot(app.UIAxes, x_data, y_data)
After this I tried in another button pushed function
cla(app.UIAxes)
and
app.UIAxes.cla
both is not working.
I am using Matlab 2019b
Eric Sargent
Eric Sargent 2020 年 12 月 9 日
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");

サインインしてコメントする。

採用された回答

Fabian Winkler
Fabian Winkler 2020 年 5 月 27 日
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.

その他の回答 (1 件)

Hadi Mahmodi
Hadi Mahmodi 2022 年 6 月 20 日
cla(app.UIAxes, 'reset')
this worked for me. Matlab 2020a

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by