Effacer les filtres
Effacer les filtres

how to write If-else statement in GUI Matlab?

3 vues (au cours des 30 derniers jours)
Ahmad Farhan
Ahmad Farhan le 13 Juin 2015
Commenté : Ahmad Farhan le 13 Juin 2015
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')

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 13 Juin 2015
Modifié(e) : Azzi Abdelmalek le 13 Juin 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
  1 commentaire
Ahmad Farhan
Ahmad Farhan le 13 Juin 2015
thank u.. i thought the way i write the 'expression' is wrong..

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by