Matlab GUI - Pushbutton internal IF condition semi-not functional

Hey Experts,
I got a problem with a GUI I am designing. I am writing some IF-ELSE IF statements inside the button as a check-condition for different increments. The relevant code can be found below.
function Simulate_Callback(hObject, eventdata, handles)
DP = str2double(get(handles.dummy, 'String'));
if (DP/handles.testdata.actualDP)*100 >=60
down =1;
elseif (DPrice/handles.testdata.actualDP)*100 < 60 && ...
(DPrice/handles.testdata.actualDP)*100 > 50
down = 0.5;
else
down = 0.05;
end
newString = sprintf('%d', int32(DP -down));
set(handles.dummy,'String',newString)
Initial value of DP is 100 and while is going down to 59 as it was supposed to (down=1), It looks like that handles.dummy does not update after that point and is stack on 59.
Any ideas guys? I can't get my mind around it.
Thanks a lot for your help! :)

 Accepted Answer

You used int32(DP -down) . int32() rounds fractional values, so if DP is an integral value, DP-0.05 or DP-0.5 is going to round to DP.
What are you expecting to have happen when you decrement by a fraction and force the result to be integer?

9 Comments

Oh my God! In that case a double() would do it !!
i have built 5 text field with labelled ( age, glucose measurement, BMI, sys, dia). may i know what went wrong?
handles.age , handles.metridata.age
handles.glucose, handles.metridata.glucose
handles.BMI, handles.metricdata.BMI
handles.sys, handles.metridata.sys
handles.dia, handles.metridata.dia
under 3 radiobutton i have setu up literally 1, 2, 3 button i have a set of if else statement
i have converted my handles to double array before setting the if else rule. howver the function does not work
% --- Executes on button press in Pregnancies.
function Female_Callback(hObject, eventdata, handles)
% hObject handle to Calculate (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
high_glucose =350;
low_glucose=0;
mean_Glucosefeat=121;
input_fuzzy_glucose=175;
high_BMI=60;
low_BMI=0;
mean_BMI=39;
input_fuzzy_BMI=30;
max_rule1=175;
max_use1=350;
max_rule2=30;
max_use2=60;
before_meal=95;
%%%%plot Predict Button if women selection button (Predict Button)
%%%%%%for women
%%% 'case1'
if (number1<=max_rule1 && number2<max_rule2 && number2<35 && number4<=113 && number5>=71)
msgbox('low risk ')
elseif (hnumber1>max_rule1 && number2==max_rule2 && number3>35 && number3<50 && number4>113 && number5<=73)
msgbox('medium risk ')
elseif (handles.Glucose<=max_rule1 && >=max_rule2 && number3>51 && number3>=60 && number4<=113 && number5<=71)
msgbox('medium risk ')
elseif(number1>=max_rule1 && number2<=max_rule2 && number3>51 && number3>=60 && number4<=127 && number5<=76)
msgbox(' risky ')
elseif(number1 <=max_rule1 && number2>=max_rule2 && number3>51 && number3>=60 && number4>=127 && number5>=76)
msgbox('risky')
elseif (number1 >max_rule1 && number2>=max_rule2 && number3>31&& number3<50 && number4>=113 && number5>=73)
msgbox('risky')
elseif(number1==max_rule1 && number2<max_rule2 && number3<35 && number4<=113 && number5<=71)
msgbox('risky')
elseif (number1 >max_rule1 && number2>=max_rule2 && number3>35 && number3<50 && number4>=113 && number5>73)
msgbox('risky')
elseif (number1>max_use1 && number2>max_use2 && number3>51 && number3>=60 &&number4<=127 && number5<=76)
msgbox('high risk')
elseif(number1 >max_rule1 && number2>max_use2 && number3>35 && number3<50 && number4>=127 && number5>=76)
msgbox('high risk')
elseif (number1 <max_rule1 && number2<max_rule2 && number4<=113 && number5<=71)
msgbox('no risk')
elseif(number1 >207 && number2>60)
msgbox('danger')
end
set(handles.Pregnancies,'Visible','on')
set(handles.Female,'Enable','on')
set(handles.Pregnancies,'Enable','on')
set(handles.Female,'Visible','on')
set(handles.Male,'Enable','on')
set(handles.Male,'Visible','on')
set(handles.Calculate,'Enable','on')
elseif (handles.Glucose<=max_rule1 && >=max_rule2 && number3>51 && number3>=60 && number4<=113 && number5<=71)
You cannot have a logical conjunction such as && right beside a comparison operator such as >=
is ther aanother way to present the if else rule withput using &&?
im trying to design an app where by if number 1 , 2,3,4,5 meet this criteria and it doesn meet this criteria it will result in certain state with only one click . please help me. thanks
elseif (number1 >max_rule1) && (number2>=max_rule2) && (number3>35 )&& (number3<50) && (number4>=117.5) && (number5>77)
msgbox('risky')
does this way helps?

Sign in to comment.

More Answers (1)

Because you're setting a control inside the function and exepcting to get it back out on a later run, you need to call guidata() to update the handles structure.

5 Comments

No, that only applies if you change what handles.dummy refers to, such as
handles.dummy = 17;
I can't really understand at which position the guidata() should be put...I'm trying to solve this since you wrote the above message...
i have an issue with my code and i cant get the function out with the radiobutton selected by designing the if else rule statement. please help!!!!
function varargout = untitled1(varargin)
% UNTITLED1 MATLAB code for untitled1.fig
% UNTITLED1, by itself, creates a new UNTITLED1 or raises the existing
% singleton*.
%
% H = UNTITLED1 returns the handle to a new UNTITLED1 or the handle to
% the existing singleton*.
%
% UNTITLED1('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in UNTITLED1.M with the given input arguments.
%
% UNTITLED1('Property','Value',...) creates a new UNTITLED1 or raises
% the existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before untitled1_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to untitled1_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 untitled1
% Last Modified by GUIDE v2.5 30-Apr-2021 18:04:40
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @untitled1_OpeningFcn, ...
'gui_OutputFcn', @untitled1_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
% --- Executes just before untitled1 is made visible.
function untitled1_OpeningFcn(hObject, ~, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to untitled1 (see VARARGIN)
% Choose default command line output for untitled1
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
initialize_gui(hObject, handles, false);
% UIWAIT makes untitled1 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = untitled1_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes during object creation, after setting all properties.
function Glucose_CreateFcn(hObject, eventdata, handles)
% hObject handle to Glucose (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu 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 Glucose_Callback(hObject, eventdata, handles)
% hObject handle to Glucose (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 Glucose as text
% str2double(get(hObject,'String')) returns contents of Glucose as a double
Glucose = str2double(get(hObject, 'String'));
if isnan(Glucose)
set(hObject, 'String',0);
errordlg('Input must be a number','Error');
end
% Save the new Glucose value
handles.metricdata.Glucose = Glucose;
guidata(hObject,handles)
% --- Executes during object creation, after setting all properties.
function BMI_CreateFcn(hObject, eventdata, handles)
% hObject handle to BMI (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu 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 BMI_Callback(hObject, eventdata, handles)
% hObject handle to BMI (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 BMI as text
% str2double(get(hObject,'String')) returns contents of BMI as a double
BMI = str2double(get(hObject, 'String'));
if isnan(BMI)
set(hObject, 'String',0);
errordlg('Input must be a number','Error');
end
% Save the new BMI value
handles.metricdata.BMI = BMI;
guidata(hObject,handles)
% --- Executes on button press in reset.
function reset_Callback(hObject, eventdata, handles)
% hObject handle to reset (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
initialize_gui(gcbf, handles, true);
% --- Executes when selected object changed in unitgroup.
function unitgroup_SelectionChangedFcn(hObject, eventdata, handles)
% hObject handle to the selected object in unitgroup
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if (hObject == handles.Female)
set(handles.text4, 'String', 'mg/dl');
set(handles.text5, 'String', 'kg/m^2');
set(handles.text11, 'String', 'mmHg');
else
set(handles.text4, 'String', 'mg/dl');
set(handles.text5, 'String', 'kg/m^2');
set(handles.text11, 'String', 'mmHg');
end
if (hObject == handles.Male)
set(handles.text4, 'String', 'mg/dl');
set(handles.text5, 'String', 'kg/m^2');
set(handles.text11, 'String', 'mmHg');
else
set(handles.text4, 'String', 'mg/dl');
set(handles.text5, 'String', 'kg/m^2');
set(handles.text11, 'String', 'mmHg');
if (hObject == handles.Pregnancies)
set(handles.text4, 'String', 'mg/dl');
set(handles.text5, 'String', 'kg/m^2');
set(handles.text11, 'String', 'mmHg');
else
set(handles.text4, 'String', 'mg/dl');
set(handles.text5, 'String', 'kg/m^2');
set(handles.text11, 'String', 'mmHg');
end
end
% ------------------------------------------------
function initialize_gui(fig_handle, handles, isreset)
% If the metricdata field is present and the reset flag is false, it means
% we are we are just re-initializing a GUI by calling it from the cmd line
% while it is up. So, bail out as we dont want to reset the data.
if isfield(handles, 'metricdata') && ~isreset
return;
end
handles.metricdata.Glucose =0;
handles.metricdata.BMI = 0;
handles.metricdata.Age = 0;
handles.metricdata.sysBP =0;
handles.metricdata.diaBP =0;
set(handles.Glucose, 'String', handles.metricdata.Glucose);
set(handles.BMI, 'String', handles.metricdata.BMI);
set(handles.sysBP, 'String',handles.metricdata.sysBP);
set(handles.diaBP, 'String',handles.metricdata.diaBP);
set(handles.Age, 'String',handles.metricdata.Age);
set(handles.unitgroup, 'SelectedObject', handles.Female);
set(handles.unitgroup, 'SelectedObject', handles.Male);
set(handles.unitgroup, 'SelectedObject', handles.Pregnancies);
set(handles.unitgroup, 'SelectedObject', handles.mmolConverter);
set(handles.text4, 'String', 'mg/dl');
set(handles.text5, 'String', 'kg/m^2');
set(handles.text11, 'String', 'mmHg');
% Update handles structure
guidata(handles.figure1, handles);
function Age_Callback(hObject, eventdata, handles)
% hObject handle to Age (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 Age as text
% str2double(get(hObject,'String')) returns contents of Age as a double
Age = str2double(get(hObject, 'String'));
if isnan(Age)
set(hObject, 'String', 0);
errordlg('Input must be a number','Error');
end
% Save the new BMI value
handles.metricdata.Age = Age;
guidata(hObject,handles)
% --- Executes during object creation, after setting all properties.
function Age_CreateFcn(hObject, eventdata, handles)
% hObject handle to Age (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 sysBP_Callback(hObject, eventdata, handles)
% hObject handle to sysBP (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 sysBP as text
% str2double(get(hObject,'String')) returns contents of sysBP as a double
sysBP = str2double(get(hObject, 'String'));
if isnan(sysBP)
set(hObject, 'String',0);
errordlg('Input must be a number','Error');
end
% Save the new Glucose value
handles.metricdata.sysBP = sysBP;
guidata(hObject,handles)
function sysBP_CreateFcn(hObject, eventdata, handles)
% hObject handle to sysBP (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 diaBP_Callback(hObject, eventdata, handles)
% hObject handle to sysBP (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 sysBP as text
% str2double(get(hObject,'String')) returns contents of sysBP as a double
diaBP= str2double(get(hObject, 'String'));
if isnan(diaBP)
set(hObject, 'String',0);
errordlg('Input must be a number','Error');
end
% --- Executes during object creation, after setting all properties.
function diaBP_CreateFcn(hObject, eventdata, handles)
% hObject handle to sysBP (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
% --- Executes on button press in Calculate.
function Calculate_Callback(hObject, eventdata, handles)
% hObject handle to Calculate (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
mmolConverter = handles.metricdata.Glucose/18;
set(handles.Calculate, 'String', mmolConverter);
% --- Executes during object creation, after setting all properties.
function Calculate_CreateFcn(hObject, eventdata, handles)
% hObject handle to Calculate (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% --- Executes during object creation, after setting all properties.
function unitgroup_CreateFcn(hObject, eventdata, handles)
% hObject handle to Calculate (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% --- Executes during object creation, after setting all properties.
function Female_CreateFcn(hObject, eventdata, handles)
% hObject handle to Calculate (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% --- Executes during object creation, after setting all properties.
% --- Executes on button press in Pregnancies.
function Female_Callback(hObject, eventdata, handles)
% hObject handle to Calculate (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
high_glucose =350;
low_glucose=0;
mean_Glucosefeat=121;
input_fuzzy_glucose=175;
high_BMI=60;
low_BMI=0;
mean_BMI=39;
input_fuzzy_BMI=30;
max_rule1=175;
max_use1=350;
max_rule2=30;
max_use2=60;
before_meal=95;
number1= str2double(set(handles.Glucose, 'String',handles.metricdata.Glucose));
number2 = str2double(set(handles.BMI,'String',handles.metricdata.BMI));
number3=str2double(set(handles.Age,'String',handles.metricdata.Age));
number4=str2double(set(handles.sysBP,'String',handles.metricdata.sysBP));
number5=str2double(set(handles.diaBP,'String',handles.metricdata.diaBP));
%%%%plot Predict Button if women selection button (Predict Button)
%%%%%%for women
%%% 'case1'
if (number1<=max_rule1 && number2<max_rule2 && number2<35 && number4<=113 && number5>=71)
msgbox('low risk ')
elseif (number1>max_rule1 && number2==max_rule2 && number3>35 && number3<50 && number4>113 && number5<=73)
msgbox('medium risk ')
elseif (number1<=max_rule1 && number2 >=max_rule2 && number3>51 && number3>=60 && number4<=113 && number5<=71)
msgbox('medium risk ')
elseif(number1>=max_rule1 && number2<=max_rule2 && number3>51 && number3>=60 && number4<=127 && number5<=76)
msgbox(' risky ')
elseif(number1 <=max_rule1 && number2>=max_rule2 && number3>51 && number3>=60 && number4>=127 && number5>=76)
msgbox('risky')
elseif (number1 >max_rule1 && number2>=max_rule2 && number3>31&& number3<50 && number4>=113 && number5>=73)
msgbox('risky')
elseif(number1==max_rule1 && number2<max_rule2 && number3<35 && number4<=113 && number5<=71)
msgbox('risky')
elseif (number1 >max_rule1 && number2>=max_rule2 && number3>35 && number3<50 && number4>=113 && number5>73)
msgbox('risky')
elseif (number1>max_use1 && number2>max_use2 && number3>51 && number3>=60 &&number4<=127 && number5<=76)
msgbox('high risk')
elseif(number1 >max_rule1 && number2>max_use2 && number3>35 && number3<50 && number4>=127 && number5>=76)
msgbox('high risk')
elseif (number1 <max_rule1 && number2<max_rule2 && number4<=113 && number5<=71)
msgbox('no risk')
elseif(number1 >207 && number2>60)
msgbox('danger')
end
set(handles.Pregnancies,'Visible','on')
set(handles.Female,'Enable','on')
set(handles.Pregnancies,'Enable','on')
set(handles.Female,'Visible','on')
set(handles.Male,'Enable','on')
set(handles.Male,'Visible','on')
set(handles.Calculate,'Enable','on')
% --- Executes during object creation, after setting all properties.
function Female_DeleteFcn(hObject, eventdata, handles)
% hObject handle to Calculate (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% --- Executes during object creation, after setting all properties.
% --- Executes during object creation, after setting all properties.
function Pregnancies_CreateFcn(hObject, eventdata, handles)
% hObject handle to Calculate (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes during object creation, after setting all properties.
% --- Executes on button press in Pregnancies.
function Pregnancies_Callback(hObject, eventdata, handles)
% hObject handle to Calculate (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
high_glucose =350;
low_glucose=0;
mean_Glucosefeat=121;
input_fuzzy_glucose=175;
high_BMI=60;
low_BMI=0;
mean_BMI=39;
input_fuzzy_BMI=30;
max_rule1=175;
max_use1=350;
max_rule2=30;
max_use2=60;
before_meal=95;
number1= str2double(set(handles.Glucose, 'String',handles.metricdata.Glucose));
number2 = str2double(set(handles.BMI,'String',handles.metricdata.BMI));
number3=str2double(set(handles.Age,'String',handles.metricdata.Age));
number4=str2double(set(handles.sysBP,'String',handles.metricdata.sysBP));
number5=str2double(set(handles.diaBP,'String',handles.metricdata.diaBP));
if(number1>=before_meal && number1>mean_Glucosefeat && number2>=max_rule2)
msgbox('high risk of diabetic')
elseif (number1<before_meal && number1<=mean_Glucosefeat && number2<max_rule2)
msgbox('normal');
elseif(number1<before_meal && number1<=mean_Glucosefeat && number2<max_rule2)
msgbox('danger');
end
set(handles.Pregnancies,'Enable','on')
set(handles.Female,'Enable','on')
set(handles.Male,'Enable','on')
set(handles.Pregnancies,'Visible','on')
set(handles.Female,'Visible','on')
set(handles.Male,'Visible','on')
set(handles.Calculate,'Enable','on')
% --- Executes during object creation, after setting all properties.
function Pregnancies_DeleteFcn(hObject, eventdata, handles)
% hObject handle to Calculate (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% --- Executes during object creation, after setting all properties.
% --- Executes during object creation, after setting all properties.
function Male_CreateFcn(hObject, eventdata, handles)
% hObject handle to Calculate (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in Pregnancies.
function Male_Callback(hObject, eventdata, handles)
% hObject handle to Calculate (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
high_glucose =350;
low_glucose=0;
mean_Glucosefeat=121;
input_fuzzy_glucose=175;
high_BMI=60;
low_BMI=0;
mean_BMI=39;
input_fuzzy_BMI=30;
max_rule1=175;
max_use1=350;
max_rule2=30;
max_use2=60;
before_meal=95;
number1= str2double(set(handles.Glucose, 'String',handles.metricdata.Glucose));
number2 = str2double(set(handles.BMI,'String',handles.metricdata.BMI));
number3=str2double(set(handles.Age,'String',handles.metricdata.Age));
number4=str2double(set(handles.sysBP,'String',handles.metricdata.sysBP));
number5=str2double(set(handles.diaBP,'String',handles.metricdata.diaBP));
%%%%%age and BP chart is base on the tpical measurement chage by age group
%%%%%found online
%%%%plot Predict Button if men selection button (Predict Button
%%%%%%for men
if (number1<=max_rule1 && number2 <max_rule2 && number3<35 && number4<=117.5 && number5>=77)
msgbox('low risk ')
elseif (number1==max_rule1 && number2>=max_rule2 && number3>35 && number3<50 && number4==117.5 && number5==77)
msgbox('medium risk ')
elseif (number1>=max_rule1 && number2==max_rule2 && number3>51 && number3>=60 && number4<=117.5 && number5==78)
msgbox('medium risk ')
elseif(number1 >=max_rule1 && number2==max_rule2 && number3>51 && number3>=60 && number4>=118 && number5<=78)
msgbox(' risky ')
elseif(number1 >max_rule1 && number2>max_rule2 && number3>51 && number3>=60 && number4<=118 && number5<=78)
msgbox('risky')
elseif (number1 <=max_rule1 && number2<=max_rule2 && number3>31&& number3<50 && number4>=118 && number5<=78)
msgbox('risky')
elseif(number1 <=max_rule1 && number2>=max_rule2 && number3<51 && number3>=60 && number4<=117.5 && number5>=77)
msgbox('risky')
elseif (number1 >max_rule1 && number2>=max_rule2 && number3>35 && number3<50 && number4>=117.5 && number5>77)
msgbox('risky')
elseif (number1>max_use1 && number2>max_use2 && number3>51 && number3>=60 &&number4<=127 && number5<=76)
msgbox('high risk')
elseif(number1 >max_rule1 && number2>max_use2 && number3>35 && number3<50 && umber4>=127 && number5>=76)
msgbox('high risk')
elseif (number1 <max_rule1 && number2<max_rule2 && number4<=117.5 && number5<=77)
msgbox('no risk')
elseif(number1 >207 && number2>60)
msgbox('danger')
end
set(handles.Pregnancies,'Enable','off')
set(handles.Female,'Enable','off')
set(handles.Pregnancies,'Visible','on')
set(handles.Female,'Visible','on')
set(handles.Male,'Enable','on')
set(handles.Calculate,'Enable','on')
% --- Executes during object creation, after setting all properties.
function Male_DeleteFcn(hObject, eventdata, handles)
% hObject handle to Calculate (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% --- Executes during object creation, after setting all properties.
Attach the fig file ane m-file with the paperclip icon.

Sign in to comment.

Categories

Find more on Graphics Object Properties in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!