MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply TodayTo resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

Asked by MathWorks Support Team on 1 Mar 2013

I would like to solve differential equations using MATLAB 8.0 (R2012b).

Answer by MathWorks Support Team on 1 Mar 2013

Accepted answer

The general workflow for solving a differential equation is:

1. Determine the type of differential equation

2. Determine the appropriate MATLAB function

3. Place the equation into the correct form

4. Determine the correct options for the numerical solver

5. Solve

6. Perform post processing if necessary

Please refer below for a more detailed descriptions:

1. Determine the type of differential equation

- Is it an ordinary differential equation. If it is, is the equation known to be stiff?

- Is it a partial differential equation? If it is,

A) How many spatial dimensions are there?

B) What is the domain?

C) What are the boundary conditions?

- Is it a stochastic differential equation?

- Is it a differential algebraic equations?

- In all of the above cases, is the problem well posed? A problem is well posed if a solution exists, is unique, and depends continuously on the input data.

2. Determine the appropriate MATLAB function

For an overview of the differential equation solvers available in MATLAB, please refer to the following link:

The following are some of the functions used for different types of problems. The list below is incomplete. Please refer to the other functions referenced in the "See Also" section of each function's documentation page. Functions do not require additional toolboxes unless otherwise indicated.

ODE:

Non-stiff: ODE45

Stiff: ODE23s, ODE115

PDE:

Parabolic/Elliptic, 1 spatial dimension: PDEPE

Elliptic, 2 spatial dimension: ASSEMPDE in the Partial Differential Equation Toolbox

Parabolic, 2 spatial dimension: PARABOLIC in the Partial Differential Equation Toolbox

Hyperbolic, 2 spatial dimensions: HYPERBOLIC in the Partial Differential Equation Toolbox.

There is no built-in functionality for three or more spatial dimensions.

Stochastic ODEs:

- SDE in the Econometrics Toolbox.

- SBIOENSEMBLERUN in the SimBiology Toolbox

DAE: ODE15S and ODE23T

3. Place the differential equation into the correct form

This will depend on the function chosen in step 2. For example, you may need to reduce a second order of an ODE to a system of first order ODEs.

4. Determine the correct options for the numerical solver

Each solver uses a different set of options. You will need to refer to the documentation for the function that was chosen in step 2.

5. Solve

6. Perform post processing if necessary.

Generally, post processing falls into one of three categories

- Interpolation the solution returned by the solver

- Plotting the solution

- Error analysis

Useful functions are GRIDDEDINTERPOLANT, PDEVAL, and PDESURF in the Partial Differential Equation Toolbox.

Many problems cannot be directly solved by one of the MathWorks provided numerical solvers in MATLAB. For example, there exists no solver for hyperbolic problems in one spatial dimension. There are several options:

- Write your own solver using other MathWorks functionality.

- Transform the problem into an equivalent problem that can be solved by one of the built in tools.

- Check the File Exchange at MATLAB Central. Please remember that that files posted to this site are not officially supported MathWorks products.

## 0 Comments