function d = compute_I_control(d,t) for i = 1:d.p.K_b if t == 1 % It is the first time step; previous value of v(i,t) % does not exist. Choose v(i,t) = v_max_traffic(i,t) d.s.v(i,t) = d.s.v_max_traffic(i,t); else % compute v(i,t) according to the I-control law d.s.v(i,t) = d.s.v(i,t-1) + d.p.K_I*d.s.e(i,t); % saturate v(i,t) between bounds imposed by traffic d.s.v(i,t) = ... max(min(d.s.v(i,t),... d.s.v_max_traffic(i,t)),d.s.v_min_traffic(i,t)); end end end