MATLAB: How to clear all the text in all TextArea components in App Designer

MATLAB

I have an app with many TextArea components in my app created with MATLAB R2019a.
I would like to design a 'clear' button with a callback function which can clear all the text in the TextArea.
I know how to clear the text for each TextArea component one-by-one. However, because I have many TextArea components, I am looking for a programmatic way to clear all TextArea components.
How do I do that?

Best Answer

Try the follow command:
h=findall(app.mainWindow,'Type','UITextArea');
for i=1:numel(h)
h(i).Value='';
end
The 'findall' functions find all the handle of the UITextArea components. And you can loop through all the handles to set the value as empty.