I have a UI table which populates other UI tables with data based on which row is currently selected, using the CellSelectionCallback function. Unfortunately, when I modify or remove rows in this master UI table, MATLAB appears to execute the CellSelectionCallback function, which throws an error at one of my conditional statements. I suspect that MATLAB is deselecting whatever cell had been selected previously and this is causing the eventdata.Indices variable to become empty or no longer in a recognized format, but my efforts to put corrective conditional statements (isempty, isnull, is < 1) in there to catch this have failed to fix the problem. I've tried putting debug breakpoints in the CellSelectionCallback function to see what's going on, but for some reason MATLAB ignores them. This question was asked a number of years ago, but apparently never answered. Anyone know what kind of conditional statements I could put in the SelectionCallback that could catch this issue? Many thanks in advance!
The error message MATLAB generates is below. tab_Category is the name of the uitable, and the "if all…" function on line 97 is my conditional statement for performing normal GUI tasks:
Index exceeds matrix dimensions.
Error in KeywordInputDiag>tab_Category_CellSelectionCallback (line 97) if all(~cellfun(@isempty,temp(eventdata.Indices(1),1:2)))
Error in gui_mainfcn (line 96) feval(varargin{:});
Error in KeywordInputDiag (line 42) gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)KeywordInputDiag('tab_Category_CellSelectionCallback',hObject,eventdata,guidata(hObject))
Error while evaluating uitable CellSelectionCallback
Best Answer