How to read data in app.UITable?

19 views (last 30 days)
Philip Chen
Philip Chen on 4 Nov 2021
Edited: Dave B on 4 Nov 2021
I want to read csv data to the app.UITable that I created in my GUI app. But when I pressed the button that reads the CSV file, the data is read in a table generated from a new window, rather than the UITable in the GUI window.
How can I fix this?
function BrowseforExcelfileButtonPushed(app, event)
t = readtable('Calibration243A.csv');
vars = {'Tone','Unit','Value'};
t = t(1:11,vars);
%Create a table UI component, and specify t as the data.
fig = uifigure;
uit = uitable(fig,'Data',t);
end

Answers (1)

Dave B
Dave B on 4 Nov 2021
Edited: Dave B on 4 Nov 2021
Instead of creating a new figure (with the uifigure function) and a new uitable (with the uitable function), just set the Data property on your existing app.UITable (I'm assuming you already have a property in your app called UITable, but if that's not what it's called use whatever name)
app.UITable.Data = t;

Categories

Find more on Develop uifigure-Based Apps in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!