How to read data in app.UITable?

22 次查看(过去 30 天)
Philip Chen
Philip Chen 2021-11-4
编辑: Dave B 2021-11-4
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

回答(1 个)

Dave B
Dave B 2021-11-4
编辑:Dave B 2021-11-4
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;

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by