MATLAB: How to write If-else statement in GUI Matlab

guiif statementMATLABmatlab gui

hi, I would like to display massage box on a GUI screen based on value of 'sum' operation. i have 2 editBox and user need to enter 2 value on those box. then, i will click on pushbutton called "SUM". based on the answer, if the value is between 0-0.5, the massage box will display "INSECURE". if the answer is between 0.6-1.0, the massage box will display "HIGH". i have write some coding but it can't RUN. can anyone help me? Thanks
% --- Executes on button press in sumbutton.
function sumbutton_Callback(hObject, eventdata, handles)
% hObject handle to testingbutton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
val = str2num(get(handles.input1,'String')) + str2num(get(handles.input2,'String'));
if (val >= 0 && val <= 0.5)
msgbox('Your System is INSECURE')
if (val >= 0.6 && val <= 1)
msgbox('Your System is SECURE')

Best Answer

% --- Executes on button press in sumbutton.
function sumbutton_Callback(hObject, eventdata, handles)
% hObject handle to testingbutton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
val = str2num(get(handles.input1,'String')) + str2num(get(handles.input2,'String'));
if (val >= 0 && val <= 0.5)
msgbox('Your System is INSECURE')
elseif (val >= 0.6 && val <= 1)
msgbox('Your System is SECURE')
end
Related Question