MATLAB: How to solve this 2nd order ODE with time-dependent parameters

2nd order odeaccelerationode45position;symbolic parameterstime-dependent parametersvelocity

2nd ODE to solve
dx/dt*(a + f(t))* d2x/dt2 + 0.5*b*(dx/dt)^2 + k(t)*(dx/dt)^2 - g(t) = 0
Boundary condition: dx/dt(0) = v0
where
- 't' is the time,
- 'x' is the position
- 'dx/dt' is the velocity
- 'd2x/dt2' is the acceleration
- 'a', 'b', 'v0' are constants
- 'f(t)', 'k(t)' and 'h(t)' are KNOWN functions dependent on 't'
(I do now write them because they are quite big)
Since I am new in Matlab, I would like to know how to code this with ode45. Thank you in advance

Best Answer

v0 = ...;
tstart = ...;
tend = ...;
a= ...;
b =...;
fun=@(t,y)(g(t)-(0.5*b+k(t))*y(1)^2)/(y(1)*(a+f(t)));
[T,Y]=ode45(fun,[tstart tend],v0);
Best wishes
Torsten.