MATLAB: Error set data of table by using eventdata.Indices inside CellSelectionCallback

cellselectioncallbackeventdata.indicesguidematlab guiset data of tabletableuitable

Hallo everyone,
this Error Shows up only after using set(handles.table,'Data',data):
Index exceeds matrix dimensions.
Error in GUI1>table_CellSelectionCallback (line 3197)
row_s = eventdata.Indices(1,1);
table has two columns (students and presence ) and rows(depending on how many Student in the class. let's say 10).
what i want is: if the the teacher clicks on the name of any Student (column student), on the table (cloumn presence) should marked true.
this my code Looks like:
function table_CellSelectionCallback(hObject, eventdata, handles)
row_s = eventdata.Indices(1,1);
col_s = eventdata.Indices(1,2);
%row_s = eventdata.Indices(1); % I tried this too, it gave the same Error
%col_s = eventdata.Indices(1); % I tried this too, it gave the same Error
data=eventdata.Source.Data
data(row_s,(col_s+1))={[true]}; % or olny true witout {[]} is the same result
% data(row_s,(col_s+1))=true; % tried this too, it gave the same result (Error)
set(handles.table,'Data',data)
I appreciate any help

Best Answer

hi everyone,
i solved that Problem and here is how i did that.
if someone wants to click on any casket of the table and get its indices and make a changes(somewhere with a Funktion on the the same table) and set that table, he should use CellEditCallBack instead of CellSelectionCallback to avoid that Problem which is:
Index exceeds matrix dimensions.
Error in GUI1>table_CellSelectionCallback (line 3197)
row_s = eventdata.Indices(1,1);
Note: the column, which you wanna click on, should be Editable.
so you should first set the column. set(handles.table.'ColumnEditable', 'On')