-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquestion1.m
More file actions
38 lines (38 loc) · 1.3 KB
/
Copy pathquestion1.m
File metadata and controls
38 lines (38 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
%Question 1
tspan = [0 4];
I0 = 0;
G0 = 0;
%For a normal person
%For a step input
[t,y1] = ode23(@(t,y) [-0.8 0.2;-5 -2]*y+[0 1]', tspan, [I0 G0]);
figure;
plot(t,y1(:,1),'--',t,y1(:,2),'-*');
xlabel('Time(Hours)');
ylabel('Insulin(u/kg) & Glucose(g/kg)');
title('Simple glucose model for a normal person for step input');
legend('Insulin', 'Glucose');
%For a delta function
[t,y2] = ode23(@(t,y) [-0.8 0.2;-5 -2]*y+[0 1-sign(t)]', tspan, [I0 G0]);
figure;
plot(t,y2(:,1),'--',t,y2(:,2),'*-');
xlabel('Time(Hours)');
ylabel('Insulin(u/kg) & Glucose(g/kg)');
title('Simple glucose model for a normal person for bolus input');
legend('Insulin', 'Glucose');
%For a diabetic patient
%For a step input
[t,y3] = ode23(@(t,y) [-0.8 0.02;-5 -2]*y+[0 1]', tspan, [I0 G0]);
figure;
plot(t,y3(:,1),'--',t,y3(:,2),'-*');
xlabel('Time(Hours)');
ylabel('Insulin(u/kg) & Glucose(g/kg)');
title('Simple glucose model for a diabetic patient for step input');
legend('Insulin', 'Glucose');
%For a step input with glucose infusion
[t,y3] = ode23(@(t,y) [-0.8 0.02;-5 -2]*y+[0.1 1]', tspan, [I0 G0]);
figure;
plot(t,y3(:,1),'--',t,y3(:,2),'-*');
xlabel('Time(Hours)');
ylabel('Insulin(u/kg) & Glucose(g/kg)');
title('Simple glucose model for a diabetic patient with glucose infusion');
legend('Insulin', 'Glucose');