Filter löschen
Filter löschen

How to clear all handles of style or type 'text' or 'static text' in Matlab GUI ?

7 Ansichten (letzte 30 Tage)
I have a matlab GUI which has 30 static text boxes (handles),
I have to clear all of them before running the program again
ex:
set(handles.tumor_volue_value, 'string', num2str(tumor_volume));
set(handles.density_value, 'string', num2str(density));
set(handles.stdDensity_value, 'string', num2str(std_Density));
and so on.. 30 of this.... Is a there a single command to clear all the handles.'*' ..which are of style 'text'..
Thanks,
Gopi

Akzeptierte Antwort

michio
michio am 3 Sep. 2016
Have you considered using findobj function? It locates graphics objects with specific properties.
h = findobj(objhandles,'PropertyName',PropertyValue);
restricts the search to objects listed in objhandles and their descendants. For example,
h = findobj(gca,'Type','line')
finds all line objects in the current axes. Please do
doc findobj
to see more details.
  4 Kommentare
michio
michio am 3 Sep. 2016
If I assume correctly, the static text you mentions is a uicontrol object with the 'Type' property being 'uicontrol' and 'Style' property being 'text'. If so, I am guessing if you execute the following command,
lh = findobj(gcf,'Style','text');
lh will be a list of graphs handles of the static text that exists on your GUI, represented by gcf. Then you can try the following to set 'String' properties to 'clear all of the text'.
set(lh,'String','')
Let me know how to goes.
Gopichandh Danala
Gopichandh Danala am 7 Sep. 2016
It didn't work for me but I understood what you explained I will use your idea and work on it.. thanks.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Graphics Object Programming finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by