Create a uitable with dynamic rows in GUIDE
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
yu yue
am 26 Okt. 2016
Beantwortet: Image Analyst
am 5 Nov. 2016
I'm writing a GUI with GUIDE.
I wanted to create a table with dynamic features. For example: I input an integer [i]. How can I tell Matlab to create [i] rows in my table? The columns are fixed. How can I dynamically change variable 'd' to [i x 7]?
f = figure;
d={[],[],[],[],[],false,[];[],[],[],[],[],false,[];[],[],[],[],[],false,[];[],[],[],[],[],false,[];[],[],[],[],[],false,[];[],[],[],[],[],false,[];[],[],[],[],[],false,[];[],[],[],[],[],false,[];[],[],[],[],[],false,[]};
columnformat = {'numeric', 'numeric','numeric','numeric','numeric','logical','numeric'};
columneditable = [ true true true true true true true];
rowname = {'1','2','3','4','5','6','7','8','9'};
t = uitable(f,'Data',d,...
'ColumnName', [],...
'ColumnFormat', columnformat,...
'ColumnEditable', columneditable,...
'RowName',rowname,'Position',[15 20 550 300]);
Thank you.
0 Kommentare
Akzeptierte Antwort
Nick Counts
am 5 Nov. 2016
Bearbeitet: Nick Counts
am 5 Nov. 2016
You can define a default row cell and use repmat() to build a cell array of the size you want:
i = 7
defaultRow = {[],[],[],[],[],false,[]}
d = repmat(defaultRow, [i,1])
Hope that helps
0 Kommentare
Weitere Antworten (1)
Image Analyst
am 5 Nov. 2016
Just make up d and set the data property of the uitable equal to d. The table will spring-adjust to the same number of rows as d has.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Migrate GUIDE Apps 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!