How to display an sql data Table in a uitable
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Oussama Louati
am 21 Nov. 2018
Kommentiert: Kojiro Saito
am 30 Nov. 2018
Hallo every one
How to Upload/ Display a an SQL data Table in a uitable,
Thank you in advance.
0 Kommentare
Akzeptierte Antwort
Kojiro Saito
am 27 Nov. 2018
From R2018a, we can display table array data in uitable.
The following is an example of reading data from PostgreSQL and show it in uitable.
%% Access to database
conn = database('db_name','usename', 'password', ...
'Vendor','PostgreSQL', ...
'Server','localhost','PortNumber',5432);
tableName = 'table_name';
% Read data from SQL
data = sqlread(conn, tableName);
%% plot in uitable
f = uifigure;
uit = uitable(f, 'Data', data);
4 Kommentare
Kojiro Saito
am 30 Nov. 2018
uitable has a property CellSelectionCallback, and by using this, selected lines can be caught up.
Here is an example of do something from selected lines (app.data and app.selected are properties added in AppDesigner)
app.UITable.CellSelectionCallback = {@selectedChange, app};
function selectedChange(src, eve, app)
% Get selected lines
app.selected = eve.Indices(:, 1);
% Extract only selected lines from original data
selectedData = app.data(app.selected, :);
% Do something on selected lines
% for example,
% m = mean(selectedData);
end
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!