write a struct to a ui table
Show older comments
how to write a struct to a ui table in appdesigner
Accepted Answer
More Answers (1)
chrisw23
on 9 Sep 2022
0 votes
structDef = struct("field1",0,"field2",0); % definition
defaultTbl = repmat(struct2table(structDef),10,1); % default empty 10row table
app.UITable.Data = defaultTbl; % copy table to uitable Data property
app.UITable.ColumnName = tbl.Properties.VariableNames; % copy variable names(table) to column names(uitable)
data1 = structDef; % empty struct copy
data1.field1 = 333; % example field data
data1.field2 = 666;
targetRow = 3;
app.UITable.Data(targetRow,:) = struct2table(data1); % write struct data to table row
Another example to show the diffs between table and uitable, because there's only a struct2table() function.
Categories
Find more on Develop Apps Using App Designer in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!