In Matlab app designer, how do I update the content of a table with data from a file specified by the user?
4 views (last 30 days)
Show older comments
I have a table in my app. When the app starts the table is empty. I created a menu so the user can load/open a file (using uigetfile). I want the table to be automatically updated/filled with the data from the file once the user opens the file. How do i do this? Thanks, José
0 Comments
Answers (1)
Jayanti
on 12 Feb 2025
Hi,
To update the table with data present in the file you can setup a callback function for the menu item created. This function will be triggered when the user selects the menu to open a file.
Given that you are using “uigetfile”, you can read the file path obtained from its output and then assign the data from the file to the “Data” property of the app’s “UITable” component. Additionally, you can set the column names of the “UITable” to match with the coumn names of the table.
You can refer to the below code snippet for your reference:
data = readtable(fullFilePath);
app.UITable.Data = data;
app.UITable.ColumnName = data.Properties.VariableNames;
For more detailed information on how to add a table and populate it with data please see the below official documentation link:
0 Comments
See Also
Categories
Find more on Workspace Variables and MAT Files 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!