Custom periodic function without counter

后端 未结 3 1056
我在风中等你
我在风中等你 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:49

    If you have the Signal Processing Toolbox, you can use something like:

    >> t = 0:3600;
    >> y = pulstran(t,[660:720:3600],'rectpuls',120);
    >> plot(t,y)
    >> ylim([-0.1 1.1])
    

    which gives the following (in Octave, should be the same in MATLAB):

    enter image description here

    You then need to scale y to be between Q1 and Q2 instead of 0 and 1.

提交回复
热议问题