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

6 visualizaciones (últimos 30 días)
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

Respuesta aceptada

michio
michio el 3 de Sept. de 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 comentarios
michio
michio el 3 de Sept. de 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 el 7 de Sept. de 2016
It didn't work for me but I understood what you explained I will use your idea and work on it.. thanks.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by