Is it possible to design a Matlab gui, with buttons that appear based on user input?
3 views (last 30 days)
Show older comments
I am trying to design a GUI for a function that multiplies N-matrices, with each matrix containing elements that are defined by several variables unique to that matrix. I would like to prompt the user to input how many matrix elements he/she wishes to multiply, and then populate the GUI with N "Edit Text" fields so the user can input the necessary parameters to define each matrix. The difficulty is, N will be different each time, so N "Edit Text" fields must be created after N is set. Does anybody know how to do this?
0 Comments
Answers (1)
Walter Roberson
on 9 Oct 2015
The most difficult part of this is getting nice Position for them. Otherwise you just loop creating uicontrol().
2 Comments
Walter Roberson
on 9 Oct 2015
The output of uicontrol() is the handle to the uicontrol graphic object. If you are using R2014a or earlier, the handle is represented as a double precision number that would internally be looked up in a table to find the data. If you are using R2014b or later, you get a handle to an Object in the Object Oriented Programming sense.
Whether you store into x or x(i) depends on whether you need to reference the individual values after the loop. Often you do, but not always.
You can assign actions at the time you create the uicontrol, by passing a 'Callback' property into the uicontrol() call. Or you can set() the properties later. Or use dot syntax if you are using R2014b or later.
To retrieve the contents of the text field, you need to get a handle to the object somehow (such as by looking in your x vector), and then you get() the String property, or you can use dot notation if you are using R2014b or later
x(5).String
I suggest that you use the command
dbtype inputdlg
and look to see how it works.
See Also
Categories
Find more on Migrate GUIDE Apps in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!