File Exchange

image thumbnail

Blood Glucose Regulation in a Type-I Diabetic in Simulink

version (78.3 KB) by

Control blood sugar levels by adjusting insulin injection pump rate



View License

This artificial pancreas simulation has a continuous glucose monitor, an insulin injection pump, and a potential PID controller. This process control project is described here:

A recent video by Dr. Ali Cinar on the topic of Artificial Pancreas Progress is provided below:

Additional course material on Process Dynamics and Control is provided at the following link:

Comments and Ratings (4)

Sagun Katta

Hi everyone,

Could anyone, please explain this part of the code? What do these values represent in the row matrix ?

% initialize the initial conditions
% SS for insulin injection of 2.0.
%x0 = [112.4400 22.2230 22.2220 11.1110 11.1110 166.6700]';
% SS for insulin injection of 3.0.
x0 = [ 76.2159 33.3333 33.3333 16.6667 16.6667 250.0000]';

i couldn' t find the source of these models,

Model source:
% R. Palma and T.F. Edgar, Toward Patient Specific Insulin Therapy: A Novel
% Insulin Bolus Calculator. In Proceedings Texas Wisconsin California Control
% Consortium, Austin, TX, Feb. 7-8, 2011.
% Expanded Bergman Minimal model to include meals and insulin
% Parameters for an insulin dependent type-I diabetic

How are these equations formed ? could anyone explain about these equations and parameters mean or how they are obtained ?

gb = 291; % Basal Blood Glucose (mg/dL)
p1 = 3.17e-2; % 1/min
p2 = 1.23e-2; % 1/min
si = 2.9e-2; % 1/min * (mL/micro-U)
ke = 9.0e-2; % 1/min
kabs = 1.2e-2; % 1/min
kemp = 1.8e-1; % 1/min
f = 8.00e-1; % L
vi = 12.0; % L
vg = 12.0; % L

% Compute ydot:
sys(1,1) = -p1*(g-gb) - si*x*g + ...
f*kabs/vg * g_gut + f/vg * d; % glucose dynamics
sys(2,1) = p2*(i-x); % remote insulin compartment dynamics
sys(3,1) = -ke*i + ui; % insulin dynamics
sys(4,1) = ui - kemp * q1;
sys(5,1) = -kemp*(q2-q1);
sys(6,1) = kemp*q2 - kabs*g_gut;

Thank you,

Albert Verry

hello dr ali cinar
This topic is my thesis master ! and your matlab codes get me spme errors,would you please send me the current codes in my mail?


Might be interesting but it contains several errors. The input to the meal model is insulin infusion rate (sys(4,1) = ui - kemp * q1) instead of ingested glucose. Moreover, the meal input affects the blood glucose directly (the term +f/vg*d in the first equation), thus bypassing completely the meal model. I am afraid that with these errors the model is useless.

MATLAB Release Compatibility
Created with R2014b
Compatible with any release
Platform Compatibility
Windows macOS Linux

MATLAB Online Live Editor Challenge

Win cash prizes and have your live script featured on our website

Learn more

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video