MATLAB: Select a cell from a uitable using two edit boxes

programmatically selectscrollselect celluitable

Hi, I'm working on a GUI and i would like to select a cell from an uitable using two edit boxes, one for the row and the second for the column instead of clicking directly on the cell, as the table is very big. I've tried several things with the CellSelectionCallback but haven't reached a solution.
Thanks in advance

Best Answer

Matlab R2021a and later
Starting in Matlab R2021a, you can programmatically scroll to any row, column, or cell of a uitable using the scroll function (see Four New App Features in MATLAB R2021a).
Syntax examples:
Prior to R20201a
Here's a method to programmatically select a cell which highlights the chosen cell as if it were just selected manually. This requires FEX: findjobj(); credit to this answer .
% Create a working UI table for the example
f = figure;
t = uitable(f,'Data',randi(100,10,3),'Position',[20 20 262 204]);
% Select row and col numbers
row = 2;
col = 3;
% Select cell programmatically
jUIScrollPane = findjobj(t);
jUITable = jUIScrollPane.getViewport.getView;
jUITable.changeSelection(row-1,col-1, false, false);
If you're trying to act on that cell by applying a function to the cell's content, you might not have to actually highlight it and you could avoid the 3rd party function.