How to store all values from cells i have edited in uitable.

1 次查看(过去 30 天)
This part of the code refreshes everytime a cell is edited so the whole of handles.storedvals is overwritten, thus only displaying the value of the most recently edited cell. Is there a way to hold the values of all cells that were edited?
function uitable1_CellEditCallback(hObject, eventdata, handles)
% hObject handle to uitable1 (see GCBO)
% eventdata structure with the following fields (see MATLAB.UI.CONTROL.TABLE)
% 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 to appropriate value for Data
% handles structure with handles and user data (see GUIDATA)
data = get(hObject, 'Data');
indices = eventdata.Indices;
r = indices(:,1);
c = indices(:,2);
linear_index = sub2ind(size(data),r,c);
storedvals(linear_index) = data(linear_index);
handles.storedvals = storedvals;
guidata(hObject, handles);

采纳的回答

Walter Roberson
Walter Roberson 2018-2-19
Before
storedvals(linear_index) = data(linear_index);
do
if isfield(handles, 'storedvals')
storedvals = handles.storedvals;
else
storedvals = nan(1, numel(data));
end

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Whos 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by