Azzera filtri
Azzera filtri

delete text from plot in app designer

8 visualizzazioni (ultimi 30 giorni)
acegi bdegi
acegi bdegi il 2 Gen 2018
Spostato: Voss il 22 Dic 2023
Using app designer, after implementing text in a plot I want to delete this text. So far, I did not succeed in doing this.
I am using a UIAxes, a text edit field and three buttons. The first button loads the graph, the second one puts in the text that is written in the text edit field and the third button deletes all text.
Here the code:
button 1 (create figure)
aa = [1 2 3 4 5];
bb = [7 3 4 6 3];
plot(app.UIAxes,aa,bb)
% use private property
app.aa = aa;
app.bb = bb;
button 2 (put in the text)
% load variables
aa = app.aa;
bb = app.bb;
c = app.EditField.Value;
text(app.UIAxes,aa(3),bb(3),sprintf('%s',c));
button 3 (delete text) (This one does not work)
delete(findobj(app.UIAxes,gca,'type','text'))
The delete button should find the text in the app.UIAxes and delete this. But instead, it opens an empty figure and gives an error. (error using matlab.ui.control.UIAxes/findobj)
It works fine in a matlabscript, but something is going wrong in app designer.
How to fix this?

Risposta accettata

acegi bdegi
acegi bdegi il 3 Gen 2018
Spostato: Voss il 22 Dic 2023
Found it.
The gca has to be removed,
delete(findobj(app.UIAxes,'type','text'));
as App Designer cannot handle gca commands. That is the greatest downside of App Designer, a lot of functions are not supported.

Più risposte (0)

Categorie

Scopri di più su Develop Apps Using App Designer in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by