I am using ode45 to solve a simple ODE:
ode45
function dCdt=u_vent(t,C) if t> 600 && t<= 720 Q=Q2; elseif t> 1320
Not necessarily the best approach, because continuity assumptions remain broken, but the way to generate a rectangular pulse train without the if chain is:
Q = Q2 + (Q1 - Q2) * (mod(t, period) < t_rise);
which works in both scalar and vector context.