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

40 visualizzazioni (ultimi 30 giorni)
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.

Risposte (1)

Shanmukha Voggu
Shanmukha Voggu il 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!

Categorie

Scopri di più su Develop Apps Using App Designer in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by