MATLAB Ordinary differential equations

After reading the MATLAB Ordinary differential equations topic, you will able to implement and solve differential equations in MATLAB.

An ODE is a differential equation with an independent variable, a dependent variable, and having some initial value for each variable.

Steps for solving a differential equation using MATLAB

  • Create a function or an anonymous function for the given problem.
  • Select ODE solver
  • Use ODE command to solve ODE.

Note:- See on the MATLAB contents, for creating a function or anonymous function.

ODE solver

MATLAB provides various inbuilt ODE solvers as shown below to solve ODE.

SolverDescriptionMethod
ode45Nonstiff differential equationsRunge-Kutta
ode23Nonstiff differential equationsRunge-Kutta
ode113Nonstiff differential equationsAdams
ode15sStiff differential equationsNDFs
ode23sStiff differential equationsRosenbrocks
ode23tModerately stiff differential equationsTrapezoidal rule
ode23tbStiff differential equationsTR-BDFs

ODE command

ODE command is used to solve an initial value ODE problem. The general form is:

[t,y] = ODE_name(ODEfun,tspan,y0)

where,

  • ODE_name Is the name of the solver (numerical method).
  • ODEfun is the name of an anonymous function.
  • tspan is the interval of the solution.
  • y0 is the initial value of y.

Example

Aim (1): To solve differential equation given below, using MATLAB.

$\frac{{dy}}{{dt}} ={t^3}$

for 1 ≤ t ≤ 3 with y = 4.2  at t = 1

Program (1):

Output (1):

ode1 =

@(t,y)(t^3)

Leave a Comment

error: Content is protected !!