You cannot use the ode45 function directly in the above example code as it will output integrated function values for all the time points instead of a single time-step value as required here. However, you can implement single-step updates of higher order methods such as Runge-Kutta (https://en.wikipedia.org/wiki/Runge%2525E2%252580%252593Kutta_methods ) instead of the Euler method for better accuracy.
Best Answer