MATLAB: Uitable checkbox in GUI

check box;uitable

raw={'p1','p2','p3'}; %points id
column1=[200;250;300]; %distances
column1=num2cell(column1);
cellArray=[raw,column1];
set(handles.uitable1, 'Data', cellArray); %predetermined blank uitable in GUI
%I wanna create blank check box (false and adjustable) for each rows in uitable. When I click on any checkbox in uitable (false to true) belongs to its row, I want to retrieve this row's distance (column 1) for some calculation in editor page.

Best Answer

'ColumnFormat', 'logical'
'CellEditCallback', set it to a function handle
If this function is called as a function handle, uitable passes it two arguments. The first argument, source, is the handle of the uitable. The second argument, eventdata, is an event data structure that contains the fields shown in the following table.
So look at the eventdata parameter. It will be a structure, with a field 'Indices' that tell you the row and column the user changed. The PreviousData and NewData fields of the structure can be used to determine whether the user is turning false to true.