MATLAB: How could I solve this 2nd order ODE with ode45

2nd order2nd order odeaccelerationdsolveodeode45position;time-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

"struggling to find the syntax of ode45 and using symbolic variables"
There is NO syntax for ODE45 that will let you solve a symbolic problem. PERIOD. Nothing in the help for ODE45 ever suggested that it would solve your problem, nor should you expect it to do so.
ODE 45 is a numerical solver. It solves numeric problems, with all NUMERICAL coefficients. Wanting it to suddenly change its coding and be able to solve a symbolic problem is a bit much though.
You can try to use tools like dsolve. Why would you not try that instead, given this is a symbolic problem? If it fails, then you need to accept that not all problems have a symbolic solution. In fact the vast majority of them won't.
Related Question