working on a project and have to make sure the input in a textbox meets a requirement for both being numeric, but also not being equal to zero. So far this is my code:
function minValue_Callback(hObject, eventdata, handles)
% hObject handle to edit10 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit10 as text
% str2double(get(hObject,'String')) returns contents of edit10 as a double
user_entry_X = str2double(get(hObject,'string'));
if isnan(user_entry_X)
errordlg('You must enter a numeric value','Error!','modal')
uicontrol(hObject)
return
end
Another question is, I have two textboxes, minValue and maxValue. How can I also make sure that the data in maxValue > minValue? (Values are used in a for loop, and I thought checking before hand and showing an error would be better.)