10 | Ordinary Differential Equations (ODEs)

In this section, we use MATLAB to numerically solve ordinary differential equations (ODEs) and systems of ODEs. We will take advantage of MATLAB’s built-in solvers such as ode45.

At the end of this section you should be able to:

Solving ODEs By Hand

Analytical Solution to an ODE I: here we go through the steps of analytically solving a homogeneous first-order linear separable differential equation.

Analytical Solution to an ODE II: here we go through the steps to solve a homogeneous second-order linear differential equation

Numerical Solutions of ODEs

State Space Form

Solving ODEs numerically: when we cannot get an analytic solution to a differential equation or want to automate the process, we can instead solve for the dependent variable(s) numerically. In Matlab and most ODE solvers, we first need to put our differential equation(s) into state space form.

State Space Example 1: we take a second-order linear nonhomogeneous differential equation and rewrite it in state space form as two first-order differential equations.

State Space Example 2: we take two first-order non-linear nonhomogeneous differential equation and rewrite it in state space form as two first-order differential equations.

Applying ODE45

Using ODE45: how to use the ODE solver in Matlab once we have our system in state space form.

ODE45 Example I: solving our previous example using ODE45

ODE45 Example II: solving our previous example using ODE45. Additionally, we create the phase portrait for the system.

Physics Examples

Ballistic Physics Example: Modeling and solving the trajectory of a cannonball without air resistance.

Using Event Detection: continuing the cannonball example but stopping the ODE solver once the ball hits the ground using event detection in ODE45.

Lecture Code

Additional Resources

More