add row to table in app designer - works ... but not completely
Ältere Kommentare anzeigen
I am trying to add rows to a table by clicking a button in a GUI
the code is as follows: the table is first initialized through a first button and then the second button is supposed to fill in data (I have not found a better way to add the row of data without this initialization. It seems that after the first addition the second row fails to concatenate, although the values should be taken from the same edit boxes which are constantly updated - I can see that actually)
function ButtonPushed(app, event)
emptydata = {0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 };
set(app.UITable, 'Data', emptydata);
end
...
function ButtonPushed(app, event)
rowdata = {app.EditField2.Value app.EditField.Value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 };
% app.UITable = [app.UITable; rowdata];
app.UITable.Data = [{app.UITable.Data{:}}; rowdata];
end
1 Kommentar
dpb
am 7 Jul. 2020
I've never used UITable so no real idea how it works, but looks to me like
app.UITable.Data = [{app.UITable.Data{:}}; rowdata];
would be trying to catenate a cell containing a row vector to a cell of the existing table .Data content that would be a 2x1 cell array, not the catenation of the .Data content itself.
I dunno how the UITable stores the .Data property exactly...surely there are examples?
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Develop Apps Using App Designer finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!