Azzera filtri
Azzera filtri

how to write If-else statement in GUI Matlab?

3 visualizzazioni (ultimi 30 giorni)
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')

Risposta accettata

Azzi Abdelmalek
Azzi Abdelmalek il 13 Giu 2015
Modificato: Azzi Abdelmalek il 13 Giu 2015
% --- 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

Più risposte (0)

Categorie

Scopri di più su Interactive Control and Callbacks in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by