function [ sum_kaja, sum_sport, sum_insulin, G_mmolpL, Time ] = glucose( dt, Tmax, ins_num, kaja_num, sport_num, ins_typ_start, kaja_typ_start, sport_typ_start )


Time=0:dt:Tmax;

kaja_type = kaja_typ_start(1,1:end);
kaja_start = kaja_typ_start(2,1:end);
kaja_Egyseg = kaja_typ_start(3,1:end);

sport_type =  sport_typ_start(1,1:end);
sport_start = sport_typ_start(2,1:end);
sport_stop = sport_typ_start(3,1:end);

ins_type = ins_typ_start(1,1:end);
ins_start = ins_typ_start(2,1:end);
ins_Egyseg = ins_typ_start(3,1:end);

sum_kaja = create_kaja( dt, length(Time), kaja_num, kaja_type, kaja_Egyseg, kaja_start );
sum_sport = create_sport( dt, length(Time), sport_num, sport_type, sport_start, sport_stop );
sum_insulin = create_insulin( dt, length(Time), ins_num, ins_type, ins_Egyseg, ins_start );


G_mmolpL=zeros(1, length(Time));
G_mmolpL(1)=5.5;
m=(3-5.5)/24;


for t=2:length(Time)
G_mmolpL(t) = (-0.01 + (0.01-(-0.01)).*rand(1,1)) + G_mmolpL(t-1) + sum_kaja(t-1) - sum_sport(t-1) - sum_insulin(t-1) + m*dt;


figure(2);
plot(Time(1:t),G_mmolpL(1:t))
xlim([0 (Tmax+1)]);
ylim([2 18]);
xlabel('t [hours]')
ylabel('Glucose [mmol/L]')
pause(0.001);
end


plot(Time,G_mmolpL)
xlim([0 (Tmax+1)]);
ylim([2 18]);
xlabel('t [hours]')
ylabel('Glucose [mmol/L]')


end