Hi! I've made a couple apps with multiple editable tables, and here's how I've done it.
Disclaimer: my tables tend to be pretty small so I'm not really concerned with doing operations the most efficient way. I'm also typically pulling values out of my tables to use in calculations and then writing calculation results to other tables or plotting them. These two things drive my approach, but for your specific application there could be other drivers.
Steps:
- Initialize the tables in the startup function
app.Table1.Data={0,0,0};
updateTable1(app);
app.Table2.Data={1,1,1};
updateTable2(app);
- Create a celledit callback for each table. In the callback, I just put the updateTable_(app) function for the respective table.
function Table1CellEdit(app,event)
updateTable1(app);
end
- Create a private update table function for each table. I either store the values in the table in properties (option 1) because I use them to do other calculations throughout the app or write property values to the table (option 2) because I've calculated a quantitity and I want to display it in the table.
function updateTable1(app)
table1Data=get(app.Table1,'Data')
app.val1=table1Data{1,1};
app.val2=table1Data{1,2};
app.val3=table1Data{1,3};
table1Data{1,1}=app.val1;
table1Data{1,2}=app.val2;
table1Data{1,3}=app.val3;
app.Table1.Data=table5Data
end
- I'm not 100% sure what you mean by insert values into your second table. If you mean add rows to your table here's what I do: To insert values into my tables, I have a button to add a table row. When the row is added, it is initialized with a set of values, then I use the appropriate updateTable_(app) function for the table to store all the values into properties again. After that, I can edit the fields in the new row of the table or the previous rows without anything happening to the other rows/cells. If by insert values into the second table you mean edit the cells, having the celledit callback function for the table with the updateTable_(app) function should take care of holding previous values.
function AddRowButtonPushed(app,event)
T=app.Table1.Data;
numRow=size(T,1)+1;
newData={0,0,0};
app.val1(numRow)=newData{1,1};
app.val2(numRow)=newData{1,2};
app.val3(numRow)=newData{1,3};
app.Table1.Data=[T;newData];
updateTable1(app);
end
Hope this helps! If not, if you could provide some more details and/or some code, I could try to recreate your isssue and work it further.