How do i rewrite my code such that I clean it up using loops? I have attached the problem statement as well so the parameters are known. This problem is done and needs to be done on Matlab.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
How do i rewrite my code such that I clean it up using loops? I have attached the problem statement as well so the parameters are known. This problem is done and needs to be done on Matlab.
g = input ("Glucose level (mg/dL):")
t = input ("Time after eating (hours). Enter -1 for fasting, 0 for after eating, or a number between 2-3 for 2-3 hours after eating:")
7
if (g>=126) && (t==-1)
disp("Diabetic")
8
9.
10
elseif (g>=231) && (t==0)
disp("Diabetic")
11
12
13
14
elseif (g>=201) && (t>=2) && (t<=3)
disp("Diabetic")
15
16
17
end
18
if (g<=125) && (g>=101) && (t==-1)
disp("Prediabetic")
19
20
21
elseif (g<=230) && (g>=201) && (t==0)
disp("Prediabetic")
22
23
24
elseif (g<=200) && (g>=140) && (t>=2) && (t<=3)
disp("Prediabetic")
25
26
27
end
28
if (g>=80) && (g<=100) && (t==-1)
disp("Normal")
29
30
31
elseif (g<=200) && (g>=170) && (t==0)
disp("Normal")
32
33
34
35
elseif (g<=140) && (g>=120) && (t>=2) && (t<=3)
disp("Normal")
36
37
38
end
Transcribed Image Text:g = input ("Glucose level (mg/dL):") t = input ("Time after eating (hours). Enter -1 for fasting, 0 for after eating, or a number between 2-3 for 2-3 hours after eating:") 7 if (g>=126) && (t==-1) disp("Diabetic") 8 9. 10 elseif (g>=231) && (t==0) disp("Diabetic") 11 12 13 14 elseif (g>=201) && (t>=2) && (t<=3) disp("Diabetic") 15 16 17 end 18 if (g<=125) && (g>=101) && (t==-1) disp("Prediabetic") 19 20 21 elseif (g<=230) && (g>=201) && (t==0) disp("Prediabetic") 22 23 24 elseif (g<=200) && (g>=140) && (t>=2) && (t<=3) disp("Prediabetic") 25 26 27 end 28 if (g>=80) && (g<=100) && (t==-1) disp("Normal") 29 30 31 elseif (g<=200) && (g>=170) && (t==0) disp("Normal") 32 33 34 35 elseif (g<=140) && (g>=120) && (t>=2) && (t<=3) disp("Normal") 36 37 38 end
You have just developed a new glucose sensor for people to monitor their blood sugar and test for
diabetes. The definitions of "normal", “impaired glucose tolerance" (also called prediabetes) and
"diabetic" depend not only on the blood sugar reading, but how soon it was taken after a meal, as given
in the table below. (Note, do not use this table to make a medical diagnosis).
Glucose level (mg/dL) Fasting
After Eating
2-3 hours after Eating
Normal
80-100
170-200
120-140
201-230
140-200
Impaired Glucose
Tolerance, or
101-125
"prediabetes"
Diabetic
126+
231+
201+
Transcribed Image Text:You have just developed a new glucose sensor for people to monitor their blood sugar and test for diabetes. The definitions of "normal", “impaired glucose tolerance" (also called prediabetes) and "diabetic" depend not only on the blood sugar reading, but how soon it was taken after a meal, as given in the table below. (Note, do not use this table to make a medical diagnosis). Glucose level (mg/dL) Fasting After Eating 2-3 hours after Eating Normal 80-100 170-200 120-140 201-230 140-200 Impaired Glucose Tolerance, or 101-125 "prediabetes" Diabetic 126+ 231+ 201+
Expert Solution
steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY