How to create a resizable table based on user input using MATLAB App Designer?

31 views (last 30 days)
I am trying to create a GUI for a simulation app I have been working on. I am hoping to create a GUI where someone can type in a number of layers (corresponds to the number of rows in the table) and then enter the material, doping type, doping amount, and layer length. I am hoping to have this be resizable, meaning that depending on user input it will display an editable table with that many rows. Then I want to be access the entries of the table via the backend to use the user inputs as inputs for my simulation.
I am new to the App Designer feature of MATLAB, so any help is useful.

Answers (1)

Shanmukha Voggu
Shanmukha Voggu on 9 Mar 2022
Hi Molly,
I understood you want to create an editable table in appdesigner that can change its size dynamically according to user input.
To do this, you can create an additional button and add a callback to the button
  • The callback implements the functionality of creating the dynamic table from user defined size
function ButtonPushed(app, event)
size = [app.RowsEditField.Value app.ColumnsEditField.Value];
varTypes = strings(1,app.ColumnsEditField.Value);
varTypes = varTypes+'double';
data = table('Size',size,'VariableTypes',varTypes);
app.UITable.Data=data;
end
The app looks like follows, before clicking the Create Table Button
After the click of button, the table gets updated with the size mentioned in the two edit fields (Rows and Columns)
Finally, editing of the cells in the table can be enabled by setting the columnEditable attribute of table to true
In order to access the data or entries in the table, use the Data property of table as follows
tableData = app.UITable.Data;
I have attached the app containing the while workflow that I mentioned above.
Refer to below documentation links for more information:
  1. https://www.mathworks.com/help/matlab/ref/table.html
  2. https://www.mathworks.com/help/matlab/matlab_prog/access-data-in-a-table.html
Hope this helps!

Categories

Find more on Develop Apps Using App Designer 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!