How to clear all handles of style or type 'text' or 'static text' in Matlab GUI ?
6 views (last 30 days)
Show older comments
Gopichandh Danala
on 3 Sep 2016
Commented: Gopichandh Danala
on 7 Sep 2016
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
0 Comments
Accepted Answer
michio
on 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 Comments
michio
on 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.
More Answers (0)
See Also
Categories
Find more on Migrate GUIDE Apps in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!