Reset GUI Edit Text Field to Empty String

4 次查看(过去 30 天)
I have a reset button on my app, and 5 edit field (text) for various inputs. When pressing the reset button, it's supposed to clear the 5 text boxes to empty strings. I've tried other suggestions from other questions (like using 'set' and 'findobj') but none of them have worked. My professor said to create a string first, then set it to empty with our code, and test it with 'isempty' but he gave no further explanation.
  4 个评论
Walter Roberson
Walter Roberson 2020-2-6
set( findobj(gcf, 'type', 'uicontrol', 'style', 'text'), 'string', '')

请先登录,再进行评论。

采纳的回答

Walter Roberson
Walter Roberson 2019-10-27
app.edit1.Value = '';
app.edit2.Value = '';
app.edit3.Value = '';
app.edit4.Value = '';
app.edit5.Value = '';
if isempty(app.edit3.Value)
disp('Yes it is empty');
else
disp('No it is not empty');
end
  1 个评论
Rachel McMurphy
Rachel McMurphy 2019-10-27
Thank you! I thought I'd tried that before, but I guess I didn't do something right.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by