8 Programming a GUIDE UI
- Sums all the selected values and displays the result in the Command Window.
This code is an example of the table callback function, CellEditCallback. Associate
this function with the table CellEditCallback property to make it execute when the
end user edits a cell in the table.
function uitable1_CellEditCallback(hObject, eventdata, handles)
% hObject handle to uitable1 (see GCBO)
% eventdata structure with the following fields
% Indices: row and column indices of the cell(s) edited
% PreviousData: previous data for the cell(s) edited
% EditData: string(s) entered by the user
% NewData: EditData or its converted form set on the Data property.
% Empty if Data was not changed
% Error: error string when failed to convert EditData
data = get(hObject,'Data');
data_sum = sum(sum(data))
When the end user finishes editing a table cell, this function gets all the values in the
table and calculates the sum of all the table values. The ColumnEditable property must
be set to true in at least one column to allow the end user to edit cells in the table. For
more information about creating tables and modifying their properties in GUIDE, see
“Add Components to the GUIDE Layout Area”.
Axes
The code in this section is an example of an axes ButtonDownFcn that triggers when the
end user clicks on the axes.