Custom periodic function without counter

后端 未结 3 1062
我在风中等你
我在风中等你 2021-01-23 02:18

I am using ode45 to solve a simple ODE:

function dCdt=u_vent(t,C)
if t>   600 &&  t<= 720
    Q=Q2;               
elseif t>   1320         


        
3条回答
  •  囚心锁ツ
    2021-01-23 02:29

    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.

提交回复
热议问题