I have created a GUI to display the contents of a data structure (loaded from an xml file) in an uitable of fixed width (8 columns of information). The user can simply edit the existing data by typing in the required box and any changes are then assigned back to the variable. To make it more useful I also added a button that allows the user to add a new row to the table (for cases where the xml is originally empty or when more data needs to be added).
My uitable callback id defined as:
function uitable2_CellEditCallback(hObject, eventdata, handles)
ParticleTypeInfo = get(hObject, 'data');
assignin('base','ParticleTypeInfo',ParticleTypeInfo)
For the button to add an extra row the call back is:
function pushbutton1_Callback(hObject, eventdata, handles)
data = get(handles.uitable2,'Data');
data(end+1,:) = {''};
set(handles.uitable2,'Data',data)
This code works fine except for one problem - my columns are of mixed type. Columns 1,2 and 8 are strings while the rest are numeric. So when I add a new row, all my columns have strings.
So I tried changing to this for the button callback:
which makes everything a number. Typing a string into columns 1,2 or 8 then keeps returning NAN.
How do I fix this to add a new row of mixed types? I've already defined the column data types as text and numeric in the table editor, but I guess that only applies to the data before I add any new rows.
Could I use columnformat for any new rows added?
'columnformat',{'numeric','char','logical'},