multiple ui edit field clear using a callback

8 views (last 30 days)
John Mark Odongo
John Mark Odongo on 24 Oct 2018
Commented: John Mark Odongo on 25 Oct 2018
Is it possible to change the value of 100 edit field(4 are text 96 are numeric) UI objects without having to write code for each one of them to clear their contents. I'm using the default names EditField_1 to 100.
  1 Comment
Stephen on 25 Oct 2018
" I'm using the default names EditField_1 to 100."
Ugh, this is such bad code design (not your fault, apparently this is just how appDesigner and GUIDE work). If you had simply written your own code (which I would recommend doing), then you could have just put all of those handles into one array H, and then all you would need is one set call:
set even lets you set each object to a different value, read its help for more information.

Sign in to comment.

Accepted Answer

Jan on 24 Oct 2018
for k = 1:100
H = handles.(sprintf('EditField_%d', k));
set(H, 'String', sprintf('%g', rand));
I guessed you are working with GUIDE. It is not clear, which strings you want to insert. What is a "text" or "numeric" edit field? All these fields contain characters.

Sign in to comment.

More Answers (0)




Community Treasure Hunt

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

Start Hunting!