There are lots of questions and answers for how to delete table rows in Matlab, but none of the solutions work very well in Matlab App Developer. In my app I have a table that is populated with data entered with pushbuttons and edit field boxes. When data is entered into the table, the table grows in size by 1 row. All of that works just fine.
I want a pushbutton that will reset the table to its default size of no rows. To achieve this I created a pushbutton called "Clear" and the following code:
function ClearButtonPushed(app, event)
app.UITable.Data =[];
end
Undesirablly, this code will replace all the data in the table with zeros. After entering new data into the table, instead of appearing on the first row, the new data will appear after all the zero rows. I have attached pictures for clarificaiton. The image on the left is before hitting the clear button. The image on the right is after hitting the clear button and then entering new data for one row. I would like for the image on the right to have only one row with the new data and no zero rows.
Similarly, I would like to click on one row and then press a "delete" pushbutton to delete only that specific row. For example looking at the image on the right, the 1st column numbers are 1, 2, 3, 1. If I click on the row with the 3 then I want the sequence for the frist column to appear as 1, 2, 1 with no zero row between the 2 and the second 1.