- The first approach is to use the Symbolic Math Toolbox (See documentation). In order to solve the differential equation x" + 2 x' + x =cos(t), you can use the function dsolve (See documentation for dsolve). For example,
- Alternatively, you may want to consider numerical ordinary differential equation solvers, such as ode45 (See Documentation). Take a look at Examples 2 and 3 in the documentation. Example 2 shows how to handle higher order terms and Example 3 illustrates how to deal with time-varying terms.