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)
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é

Answers (1)

Jayanti
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’sUITablecomponent. Additionally, you can set the column names of the UITableto 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:

Community Treasure Hunt

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

Start Hunting!