values of 10 or greater are being read as strings while below are read as numerical as i put them into my gui table
Info
This question is closed. Reopen it to edit or answer.
Show older comments
pretty much the question. here's my code
function IONS_CellSelectionCallback(hObject, eventdata, handles)
% hObject handle to IONS (see GCBO)
% eventdata structure with the following fields (see UITABLE)
% Indices: row and column indices of the cell(s) currently selecteds
% handles structure with handles and user data (see GUIDATA)
handles=guidata(hObject);
handles.currentCell = eventdata.Indices;
guidata(gcf,handles);
function IONS_CellEditCallback(hObject, eventdata, handles)
% hObject handle to IONS (see GCBO)
% eventdata structure with the following fields (see UITABLE)
% 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)
meq_Na = 23;
meq_Ca = 20.04;
meq_Cl = 35.45;
meq_SO4 = 48;
mg_meq = [meq_Na, meq_Ca, meq_Cl, meq_SO4];
% equi_ions = zeros(4,2);
% handles=guidata(gcf);
Indices = handles.currentCell%eventdata.Indices(1,1)%handles.currentCell;
if Indices(2) == 1
data = (get(handles.IONS,'Data'));
if Indices(1) == 1
data{Indices(1),Indices(2)} = str2double(eventdata.NewData);
data{Indices(1),2} = str2double(eventdata.NewData)/meq_Na;
set(handles.IONS,'Data',data);
using str2double to convert the values of 10 and greater to numerical, but this doesn't work for values less than 10 and if i get rid of str2double, then everything below ten works but not above. very confused as to why it is reading double digits as strings.
1 Comment
Alex
on 9 Sep 2013
Answers (0)
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!