Functions > Solving and Optimization > Solve Block Functions > Example: Solving a First-Order System of ODEs
  
Example: Solving a First-Order System of ODEs
Use a solve block and the odesolve function to solve a system of first-order ordinary differential equations.
1. Define the endpoint of the solution interval
Click to copy this expression
2. Define the problem using derivatives and a set of initial conditions:
Click to copy this expression
3. Plot the solutions over one interval:
Click to copy this expression
Click to copy this expression
Using the Rkadapt Function
Use the Rkadapt function to solve the same system of differential equations:
1. Define a function that determines a vector of derivative values at any solution point (t,Y):
Click to copy this expression
2. Define additional arguments for the ODE solver:
a. Initial value of independent variable
Click to copy this expression
b. Vector of initial function values
Click to copy this expression
c. Number of solution values on [t0, t1]
Click to copy this expression
3. Use the Rkadapt function to find the Solution matrix:
Click to copy this expression
* 
You can also use the rkfixed, Bulstoer, or Radau functions.
4. Extract the independent variable values
Click to copy this expression
5. Extract the first solution function values
Click to copy this expression
6. Extract the second solution function values
Click to copy this expression
7. Extract the third solution function values
Click to copy this expression
8. Plot the three solutions:
Click to copy this expression
* 
The odesolve solutions plot is almost identical to the Rkadapt solutions plot.