MATLAB: Troubles with writing to an editable table.

MATLABuitable gui matlab columneditable

Hello everybody,
I'm writing a GUI, which includes a uitable(tagged uitable) with the following headers:
  • Original Gear
  • Original Shift Distance
  • New Gear
  • New Shift Distance
I'm running my program, which calculates the two original values. I send them to the uitable function by:
matrix=[Sgear Sshift];
set(handles.uitable,'Data',matrix);
guidata(hObject,handles);
thus filling two of the four columns of the table. Subsequently, I want to be able to allow the user to enter alternative values in the other two columns. To ensure this; I've set ColumnEditable to a logical of [0 0 1 1]. However, when I try to enter the values in the two blank columns, the columns do allow entering of the values, but as soon as i move on to a next cell, it returns to blank again. The EditData in the eventdata shows the correct value,the error in the eventdata shows:'Table data is not editable at this location.'
Before running the entire code, it is possible to enter data in the 2 last columns, and data remains shown as it is supposed to be. However, after running the code, and calculating the the first two columns, this is not the case anymore.
It seems to me that inserting data from another function, blocks the possibility for manual entering of the values in some way.
I hope you guys understand the issues, and give me some tips =)
Roy

Best Answer

Have you tried setting the data as cell a cell array instead of as a numeric matrix?
matrix = [ num2cell(Sgear), num2cell(Sshift) ];
set(handles.uitable,'Data',matrix);
If that was not sufficient, I would suggest
matrix = [ num2cell(Sgear), num2cell(Sshift), cell(size(Sgear,1),2) ];
set(handles.uitable,'Data',matrix);
to provide empty cells for the data to go into.