How to read data in app.UITable?

22 vues (au cours des 30 derniers jours)
Philip Chen
Philip Chen le 4 Nov 2021
Modifié(e) : Dave B le 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

Réponses (1)

Dave B
Dave B le 4 Nov 2021
Modifié(e) : Dave B le 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;

Catégories

En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by