There are several ways to communicate information between different UI elements. Here I am describing one of them. The key point is to understand the Parent and Children relation between MATLAB graphics objects. In your example, three tables are the Children of the figure window in which they are located. The easiest way for communication among several Children object is through parent object (in your case the figure window). Fortunately, in MATLAB, each graphics Object has a property called UserData, which MATLAB never uses and it is there to allow a user to store its own data. Understanding this. Here is a basic sketch what you can do,
table1 = uitable(...
table2 = uitable(...
table3 = uitable(...
f = table1.Parent;
f.UserData.tab1 = table1;
f.UserData.tab2 = table2;
f.UserData.tab3 = table3;
Now the next issue is how can we know, which cell of each table is selected. Here we will use CellSelectionCallback. The callback function will also set some fields in UserData property of figure f so that other tables can also access it. It can be done like this
f.UserData.tab1CurrentCell = [];
f.UserData.tab2CurrentCell = [];
f.UserData.tab3CurrentCell = [];
and then define callbacks like this
function table1CellSelectionCallBack(HObj, event)
HObj.Parent.UserData.tab1CurrentCell = event.Indices;
currentSelectTable2 = HObj.Parent.UserData.tab2CurrentCell;
currentSelectTable3 = HObj.Parent.UserData.tab3CurrentCell;
HObj.Parent.UserData.tab3.Data = [];
end
Similar callbacks can be written for table 2 and table 3 CellSelectionCallback. For more details on this topic, refer to my this answer.
Best Answer