function varargout = GUI(varargin) % GUI MATLAB code for GUI.fig % GUI, by itself, creates a new GUI or raises the existing % singleton*. % % H = GUI returns the handle to a new GUI or the handle to % the existing singleton*. % % GUI('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in GUI.M with the given input arguments. % % GUI('Property','Value',...) creates a new GUI or raises % the existing singleton*. Starting from the left, property value pairs are % applied to the GUI before GUI_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to GUI_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help GUI % Last Modified by GUIDE v2.5 12-May-2014 00:01:35 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @GUI_OpeningFcn, ... 'gui_OutputFcn', @GUI_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT function GUI_OpeningFcn(hObject, eventdata, handles, varargin) handles.output = hObject; guidata(hObject, handles); initialize_gui(hObject, handles, false); function varargout = GUI_OutputFcn(hObject, eventdata, handles) varargout{1} = handles.output; function time_Callback(hObject, eventdata, handles) time = str2double(get(hObject, 'String')); if isnan(time) set(hObject, 'String', 0); errordlg('Input must be a number','Error'); end handles.metricdata.time = time; guidata(hObject,handles) function time_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function dt_value_Callback(hObject, eventdata, handles) dt_value = str2double(get(hObject, 'String')); if isnan(dt_value) set(hObject, 'String', 0); errordlg('Input must be a number','Error'); end handles.metricdata.dt_value = dt_value; guidata(hObject,handles) % --- Executes during object creation, after setting all properties. function dt_value_CreateFcn(hObject, eventdata, handles) % hObject handle to dt_value (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function food1_type_box_Callback(hObject, eventdata, handles) food1_type = str2double(get(hObject, 'String')); if isnan(food1_type) set(hObject, 'String', 0); errordlg('Input must be a number','Error'); end handles.metricdata.food1_type = food1_type; guidata(hObject,handles) % --- Executes during object creation, after setting all properties. function food1_type_box_CreateFcn(hObject, eventdata, handles) % hObject handle to food1_type_box (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function food2_type_box_Callback(hObject, eventdata, handles) food2_type = str2double(get(hObject, 'String')); if isnan(food2_type) set(hObject, 'String', 0); errordlg('Input must be a number','Error'); end handles.metricdata.food2_type = food2_type; guidata(hObject,handles) % --- Executes during object creation, after setting all properties. function food2_type_box_CreateFcn(hObject, eventdata, handles) % hObject handle to food2_type_box (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function food3_type_box_Callback(hObject, eventdata, handles) food3_type = str2double(get(hObject, 'String')); if isnan(food3_type) set(hObject, 'String', 0); errordlg('Input must be a number','Error'); end handles.metricdata.food3_type = food3_type; guidata(hObject,handles) % --- Executes during object creation, after setting all properties. function food3_type_box_CreateFcn(hObject, eventdata, handles) % hObject handle to food3_type_box (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function food1_start_box_Callback(hObject, eventdata, handles) food1_start = str2double(get(hObject, 'String')); if isnan(food1_start) set(hObject, 'String', 0); errordlg('Input must be a number','Error'); end handles.metricdata.food1_start = food1_start; guidata(hObject,handles) % --- Executes during object creation, after setting all properties. function food1_start_box_CreateFcn(hObject, eventdata, handles) % hObject handle to food1_start_box (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function food2_start_box_Callback(hObject, eventdata, handles) food2_start = str2double(get(hObject, 'String')); if isnan(food2_start) set(hObject, 'String', 0); errordlg('Input must be a number','Error'); end handles.metricdata.food2_start = food2_start; guidata(hObject,handles) % --- Executes during object creation, after setting all properties. function food2_start_box_CreateFcn(hObject, eventdata, handles) % hObject handle to food2_start_box (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function food3_start_box_Callback(hObject, eventdata, handles) food3_start = str2double(get(hObject, 'String')); if isnan(food3_start) set(hObject, 'String', 0); errordlg('Input must be a number','Error'); end handles.metricdata.food3_start = food3_start; guidata(hObject,handles) % --- Executes during object creation, after setting all properties. function food3_start_box_CreateFcn(hObject, eventdata, handles) % hObject handle to food3_start_box (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function food1_Unit_Callback(hObject, eventdata, handles) food1_Unit = str2double(get(hObject, 'String')); if isnan(food1_Unit) set(hObject, 'String', 0); errordlg('Input must be a number','Error'); end handles.metricdata.food1_Unit = food1_Unit; guidata(hObject,handles) % --- Executes during object creation, after setting all properties. function food1_Unit_CreateFcn(hObject, eventdata, handles) % hObject handle to food1_Unit (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function food2_Unit_Callback(hObject, eventdata, handles) food2_Unit = str2double(get(hObject, 'String')); if isnan(food2_Unit) set(hObject, 'String', 0); errordlg('Input must be a number','Error'); end handles.metricdata.food2_Unit = food2_Unit; guidata(hObject,handles) % --- Executes during object creation, after setting all properties. function food2_Unit_CreateFcn(hObject, eventdata, handles) % hObject handle to food2_Unit (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function food3_Unit_Callback(hObject, eventdata, handles) food3_Unit = str2double(get(hObject, 'String')); if isnan(food3_Unit) set(hObject, 'String', 0); errordlg('Input must be a number','Error'); end handles.metricdata.food3_Unit = food3_Unit; guidata(hObject,handles) % --- Executes during object creation, after setting all properties. function food3_Unit_CreateFcn(hObject, eventdata, handles) % hObject handle to food3_Unit (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function insulin1_type_box_Callback(hObject, eventdata, handles) insulin1_type = str2double(get(hObject, 'String')); if isnan(insulin1_type) set(hObject, 'String', 0); errordlg('Input must be a number','Error'); end handles.metricdata.insulin1_type = insulin1_type; guidata(hObject,handles) % --- Executes during object creation, after setting all properties. function insulin1_type_box_CreateFcn(hObject, eventdata, handles) % hObject handle to insulin1_type_box (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function insulin2_type_box_Callback(hObject, eventdata, handles) insulin2_type = str2double(get(hObject, 'String')); if isnan(insulin2_type) set(hObject, 'String', 0); errordlg('Input must be a number','Error'); end handles.metricdata.insulin2_type = insulin2_type; guidata(hObject,handles) % --- Executes during object creation, after setting all properties. function insulin2_type_box_CreateFcn(hObject, eventdata, handles) % hObject handle to insulin2_type_box (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function insulin3_type_box_Callback(hObject, eventdata, handles) insulin3_type = str2double(get(hObject, 'String')); if isnan(insulin3_type) set(hObject, 'String', 0); errordlg('Input must be a number','Error'); end handles.metricdata.insulin3_type = insulin3_type; guidata(hObject,handles) % --- Executes during object creation, after setting all properties. function insulin3_type_box_CreateFcn(hObject, eventdata, handles) % hObject handle to insulin3_type_box (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function insulin1_start_box_Callback(hObject, eventdata, handles) insulin1_start = str2double(get(hObject, 'String')); if isnan(insulin1_start) set(hObject, 'String', 0); errordlg('Input must be a number','Error'); end handles.metricdata.insulin1_start = insulin1_start; guidata(hObject,handles) % --- Executes during object creation, after setting all properties. function insulin1_start_box_CreateFcn(hObject, eventdata, handles) % hObject handle to insulin1_start_box (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function insulin2_start_box_Callback(hObject, eventdata, handles) insulin2_start = str2double(get(hObject, 'String')); if isnan(insulin2_start) set(hObject, 'String', 0); errordlg('Input must be a number','Error'); end handles.metricdata.insulin2_start = insulin2_start; guidata(hObject,handles) % --- Executes during object creation, after setting all properties. function insulin2_start_box_CreateFcn(hObject, eventdata, handles) % hObject handle to insulin2_start_box (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function insulin3_start_box_Callback(hObject, eventdata, handles) insulin3_start = str2double(get(hObject, 'String')); if isnan(insulin3_start) set(hObject, 'String', 0); errordlg('Input must be a number','Error'); end handles.metricdata.insulin3_start = insulin3_start; guidata(hObject,handles) % --- Executes during object creation, after setting all properties. function insulin3_start_box_CreateFcn(hObject, eventdata, handles) % hObject handle to insulin3_start_box (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function insulin1_Unit_Callback(hObject, eventdata, handles) insulin1_Unit = str2double(get(hObject, 'String')); if isnan(insulin1_Unit) set(hObject, 'String', 0); errordlg('Input must be a number','Error'); end handles.metricdata.insulin1_Unit = insulin1_Unit; guidata(hObject,handles) % --- Executes during object creation, after setting all properties. function insulin1_Unit_CreateFcn(hObject, eventdata, handles) % hObject handle to insulin1_Unit (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function insulin2_Unit_Callback(hObject, eventdata, handles) insulin2_Unit = str2double(get(hObject, 'String')); if isnan(insulin2_Unit) set(hObject, 'String', 0); errordlg('Input must be a number','Error'); end handles.metricdata.insulin2_Unit = insulin2_Unit; guidata(hObject,handles) % --- Executes during object creation, after setting all properties. function insulin2_Unit_CreateFcn(hObject, eventdata, handles) % hObject handle to insulin2_Unit (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function insulin3_Unit_Callback(hObject, eventdata, handles) insulin3_Unit = str2double(get(hObject, 'String')); if isnan(insulin3_Unit) set(hObject, 'String', 0); errordlg('Input must be a number','Error'); end handles.metricdata.insulin3_Unit = insulin3_Unit; guidata(hObject,handles) % --- Executes during object creation, after setting all properties. function insulin3_Unit_CreateFcn(hObject, eventdata, handles) % hObject handle to insulin3_Unit (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function insulin4_type_box_Callback(hObject, eventdata, handles) insulin4_type = str2double(get(hObject, 'String')); if isnan(insulin4_type) set(hObject, 'String', 0); errordlg('Input must be a number','Error'); end handles.metricdata.insulin4_type = insulin4_type; guidata(hObject,handles) % --- Executes during object creation, after setting all properties. function insulin4_type_box_CreateFcn(hObject, eventdata, handles) % hObject handle to insulin4_type_box (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function insulin4_start_box_Callback(hObject, eventdata, handles) insulin4_start = str2double(get(hObject, 'String')); if isnan(insulin4_start) set(hObject, 'String', 0); errordlg('Input must be a number','Error'); end handles.metricdata.insulin4_start = insulin4_start; guidata(hObject,handles) % --- Executes during object creation, after setting all properties. function insulin4_start_box_CreateFcn(hObject, eventdata, handles) % hObject handle to insulin4_start_box (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function insulin4_Unit_Callback(hObject, eventdata, handles) insulin4_Unit = str2double(get(hObject, 'String')); if isnan(insulin4_Unit) set(hObject, 'String', 0); errordlg('Input must be a number','Error'); end handles.metricdata.insulin4_Unit = insulin4_Unit; guidata(hObject,handles) % --- Executes during object creation, after setting all properties. function insulin4_Unit_CreateFcn(hObject, eventdata, handles) % hObject handle to insulin4_Unit (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function insulin5_type_box_Callback(hObject, eventdata, handles) insulin5_type = str2double(get(hObject, 'String')); if isnan(insulin5_type) set(hObject, 'String', 0); errordlg('Input must be a number','Error'); end handles.metricdata.insulin5_type = insulin5_type; guidata(hObject,handles) % --- Executes during object creation, after setting all properties. function insulin5_type_box_CreateFcn(hObject, eventdata, handles) % hObject handle to insulin5_type_box (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function insulin5_start_box_Callback(hObject, eventdata, handles) insulin5_start = str2double(get(hObject, 'String')); if isnan(insulin5_start) set(hObject, 'String', 0); errordlg('Input must be a number','Error'); end handles.metricdata.insulin5_start = insulin5_start; guidata(hObject,handles) % --- Executes during object creation, after setting all properties. function insulin5_start_box_CreateFcn(hObject, eventdata, handles) % hObject handle to insulin5_start_box (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function insulin5_Unit_Callback(hObject, eventdata, handles) insulin5_Unit = str2double(get(hObject, 'String')); if isnan(insulin5_Unit) set(hObject, 'String', 0); errordlg('Input must be a number','Error'); end handles.metricdata.insulin5_Unit = insulin5_Unit; guidata(hObject,handles) % --- Executes during object creation, after setting all properties. function insulin5_Unit_CreateFcn(hObject, eventdata, handles) % hObject handle to insulin5_Unit (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function sport1_type_box_Callback(hObject, eventdata, handles) sport1_type = str2double(get(hObject, 'String')); if isnan(sport1_type) set(hObject, 'String', 0); errordlg('Input must be a number','Error'); end handles.metricdata.sport1_type = sport1_type; guidata(hObject,handles) % --- Executes during object creation, after setting all properties. function sport1_type_box_CreateFcn(hObject, eventdata, handles) % hObject handle to sport1_type_box (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function sport2_type_box_Callback(hObject, eventdata, handles) sport2_type = str2double(get(hObject, 'String')); if isnan(sport2_type) set(hObject, 'String', 0); errordlg('Input must be a number','Error'); end handles.metricdata.sport2_type = sport2_type; guidata(hObject,handles) % --- Executes during object creation, after setting all properties. function sport2_type_box_CreateFcn(hObject, eventdata, handles) % hObject handle to sport2_type_box (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function sport1_start_box_Callback(hObject, eventdata, handles) sport1_start = str2double(get(hObject, 'String')); if isnan(sport1_start) set(hObject, 'String', 0); errordlg('Input must be a number','Error'); end handles.metricdata.sport1_start = sport1_start; guidata(hObject,handles) % --- Executes during object creation, after setting all properties. function sport1_start_box_CreateFcn(hObject, eventdata, handles) % hObject handle to sport1_start_box (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function sport2_start_box_Callback(hObject, eventdata, handles) sport2_start = str2double(get(hObject, 'String')); if isnan(sport2_start) set(hObject, 'String', 0); errordlg('Input must be a number','Error'); end handles.metricdata.sport2_start = sport2_start; guidata(hObject,handles) % --- Executes during object creation, after setting all properties. function sport2_start_box_CreateFcn(hObject, eventdata, handles) % hObject handle to sport2_start_box (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function sport1_stop_box_Callback(hObject, eventdata, handles) sport1_stop = str2double(get(hObject, 'String')); if isnan(sport1_stop) set(hObject, 'String', 0); errordlg('Input must be a number','Error'); end handles.metricdata.sport1_stop = sport1_stop; guidata(hObject,handles) % --- Executes during object creation, after setting all properties. function sport1_stop_box_CreateFcn(hObject, eventdata, handles) % hObject handle to sport1_stop_box (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function sport2_stop_box_Callback(hObject, eventdata, handles) sport2_stop = str2double(get(hObject, 'String')); if isnan(sport2_stop) set(hObject, 'String', 0); errordlg('Input must be a number','Error'); end handles.metricdata.sport2_stop = sport2_stop; guidata(hObject,handles) % --- Executes during object creation, after setting all properties. function sport2_stop_box_CreateFcn(hObject, eventdata, handles) % hObject handle to sport2_stop_box (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function start_Callback(hObject, ~, handles) time_max = handles.metricdata.time; dt = handles.metricdata.dt_value; ins_typ_start_Unit = [handles.metricdata.insulin1_type, handles.metricdata.insulin2_type, handles.metricdata.insulin3_type, handles.metricdata.insulin4_type, handles.metricdata.insulin5_type; handles.metricdata.insulin1_start, handles.metricdata.insulin2_start, handles.metricdata.insulin3_start, handles.metricdata.insulin4_start, handles.metricdata.insulin5_start; handles.metricdata.insulin1_Unit, handles.metricdata.insulin2_Unit, handles.metricdata.insulin3_Unit, handles.metricdata.insulin4_Unit, handles.metricdata.insulin5_Unit ]; food_typ_start_Unit = [handles.metricdata.food1_type, handles.metricdata.food2_type, handles.metricdata.food3_type; handles.metricdata.food1_start, handles.metricdata.food2_start, handles.metricdata.food3_start; handles.metricdata.food1_Unit, handles.metricdata.food2_Unit, handles.metricdata.food3_Unit]; sport_typ_start_stop = [handles.metricdata.sport1_type, handles.metricdata.sport2_type; handles.metricdata.sport1_start, handles.metricdata.sport2_start; handles.metricdata.sport1_stop, handles.metricdata.sport2_stop]; ins_num = 5; food_num = 3; sport_num = 2; [ sum_food, sum_sport, sum_insulin, G_mmolpL, Time ] = glucose( dt, time_max, ins_num, food_num, sport_num, ins_typ_start_Unit, food_typ_start_Unit, sport_typ_start_stop ); set(handles.savedata_button,'Enable','on') set(handles.food_plot,'Enable','on') set(handles.insulin_plot,'Enable','on') set(handles.sport_plot,'Enable','on') handles.food = sum_food; handles.sport = sum_sport; handles.insulin = sum_insulin; handles.Time = Time; handles.G = G_mmolpL; guidata(hObject,handles) % --- Executes when selected object is changed in characteristics. function characteristics_SelectionChangeFcn(hObject, eventdata, handles) % hObject handle to the selected object in characteristics % eventdata structure with the following fields (see UIBUTTONGROUP) % EventName: string 'SelectionChanged' (read only) % OldValue: handle of the previously selected object or empty if none was selected % NewValue: handle of the currently selected object % handles structure with handles and user data (see GUIDATA) % --- Executes on button press in sport_plot. function sport_plot_Callback(hObject, eventdata, handles) data = handles.sport; t = handles.Time; figure(3); plot(t,data); xlabel('t [hours]') ylabel('Glucose [mmol/L]') % hObject handle to sport_plot (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % --- Executes on button press in insulin_plot. function insulin_plot_Callback(hObject, eventdata, handles) data = handles.insulin; t = handles.Time; figure(4); plot(t,data); xlabel('t [hours]') ylabel('Glucose [mmol/L]') % hObject handle to insulin_plot (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % --- Executes on button press in food_plot. function food_plot_Callback(hObject, eventdata, handles) data = handles.food; t = handles.Time; figure(5); plot(t,data); xlabel('t [hours]') ylabel('Glucose [mmol/L]') % hObject handle to food_plot (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) function reset_Callback(hObject, eventdata, handles) initialize_gui(gcbf, handles, true); function savedata_button_Callback(hObject, eventdata, handles) savedata = [ handles.Time', handles.G' ]; [file,path] = uiputfile('*.dat','Save as'); Name = fullfile(path,file); if path==0, return; end save(Name,'savedata','-ascii'); function initialize_gui(fig_handle, handles, isreset) if isfield(handles, 'metricdata') && ~isreset return; end handles.metricdata.time = 24; handles.metricdata.dt_value = 0.01; handles.metricdata.food1_type = 2; handles.metricdata.food2_type = 1; handles.metricdata.food3_type = 3; handles.metricdata.food1_start = 8; handles.metricdata.food2_start = 13; handles.metricdata.food3_start = 18; handles.metricdata.food1_Unit = 2; handles.metricdata.food2_Unit = 3; handles.metricdata.food3_Unit = 3; handles.metricdata.insulin1_type = 1; handles.metricdata.insulin2_type = 3; handles.metricdata.insulin3_type = 2; handles.metricdata.insulin4_type = 1; handles.metricdata.insulin5_type = 3; handles.metricdata.insulin1_start = 8; handles.metricdata.insulin2_start = 9; handles.metricdata.insulin3_start = 13; handles.metricdata.insulin4_start = 16; handles.metricdata.insulin5_start = 18; handles.metricdata.insulin1_Unit = 1; handles.metricdata.insulin2_Unit = 2; handles.metricdata.insulin3_Unit = 1; handles.metricdata.insulin4_Unit = 1; handles.metricdata.insulin5_Unit = 1; handles.metricdata.sport1_type = 1; handles.metricdata.sport2_type = 0; handles.metricdata.sport1_start = 16; handles.metricdata.sport2_start = 19; handles.metricdata.sport1_stop = 17; handles.metricdata.sport2_stop = 20; handles.metricdata.insulin1_type = 3; set(handles.savedata_button,'Enable','off') set(handles.food_plot,'Enable','off') set(handles.insulin_plot,'Enable','off') set(handles.sport_plot,'Enable','off') set(handles.dt_value, 'String', 0.01); set(handles.food1_type_box, 'String', 2); set(handles.food2_type_box, 'String', 1); set(handles.food3_type_box, 'String', 3); set(handles.food1_start_box, 'String', 8); set(handles.food2_start_box, 'String', 13); set(handles.food3_start_box, 'String', 18); set(handles.food1_Unit, 'String', 2); set(handles.food2_Unit, 'String', 3); set(handles.food3_Unit, 'String', 3); set(handles.insulin1_type_box, 'String', 1); set(handles.insulin2_type_box, 'String', 3); set(handles.insulin3_type_box, 'String', 2); set(handles.insulin4_type_box, 'String', 1); set(handles.insulin5_type_box, 'String', 3); set(handles.insulin1_start_box, 'String', 8); set(handles.insulin2_start_box, 'String', 9); set(handles.insulin3_start_box, 'String', 13); set(handles.insulin4_start_box, 'String', 16); set(handles.insulin5_start_box, 'String', 18); set(handles.insulin1_Unit, 'String', 1); set(handles.insulin2_Unit, 'String', 2); set(handles.insulin3_Unit, 'String', 1); set(handles.insulin4_Unit, 'String', 1); set(handles.insulin5_Unit, 'String', 1); set(handles.sport1_type_box, 'String', 1); set(handles.sport2_type_box, 'String', 0); set(handles.sport1_start_box, 'String', 16); set(handles.sport2_start_box, 'String', 19); set(handles.sport1_stop_box, 'String', 17); set(handles.sport2_stop_box, 'String', 20); set(handles.time, 'String', 24); guidata(handles.figure1, handles);