I have this 2nd order ODE to solve in Matlab:
(a + f(t))·(dx/dt)·(d²x/dt²) + g(t) + ((h(t) + i(t)·(d²x/dt² > b·(c-x)))·(dx/dt) + j(t))·(dx/dt)² + k(t)·(t > d) = 0
where
a,b,c,dare known constantsf(t),g(t),h(t),i(t),j(t),k(t)are known functions dependent ontxis the positiondx/dtis the velocityd²x/dt²is the acceleration
and notice the two conditions that
i(t)is introduced in the equation if(d²x/dt² > b·(c-x))k(t)is introduced in the equation if(t > d)
So, the problem could be solved with a similar structure in Matlab as this example:
[T,Y] = ode45(@(t,y) [y(2); 'the expression of the acceleration'], tspan, [x0 v0]);
where
Tis the time vector,Yis the vector of position (column 1 asy(1)) and velocity (column 2 asy(2)).ode45is the ODE solver, but another one could be used.tspan,x0,v0are known.the expression of the accelerationmeans an expression ford²x/dt², but here comes the problem, since it is inside the condition fori(t)and 'outside' at the same time multiplying(a + f(t))·(dx/dt). So, the acceleration cannot be written in matlab asd²x/dt² = something
Some issues that could help:
once the condition
(d²x/dt² > b·(c-x))and/or(t > d)is satisfied, the respective termi(t)and/ork(t)will be introduced until the end of the determined time intspan.for the condition
(d²x/dt² > b·(c-x)), the termd²x/dt²could be written as the difference of velocities, likey(2) - y(2)', ify(2)'is the velocity of the previous instant, divided by the step-time defined intspan. But I do not know how to access the previous value of the velocity during the solving of the ODE
Thank you in advanced !