Matlab Code for Solving Differential Equations in Chemical Engineering

Matlab programming for chemical engineering is important in designing equipment in
process engineering. In chemical engineering, we have to solve differential equations to find
relationships between different parameters such as pressure, temperature, velocity and etc.

Matlab coding for differential equation for reaction engineering

Here we see matlab codes for first order and second order differential equations. Knowing basics for
solving differential equation is a must for any chemical engineer.

These differential equations are used to solve problems of batch reactors, plug flow rectors (PFR) and
continuous stirred reactors (CSTR).

In this tutorial, we will look how to code a matlab program properly to represent a behavior of a reactor. First,
several basic codes are given to understand how to solve differential equations by matlab program.

First order differential equation matlab code with initial conditions

Here, we are going to solve first order differential equation, dy/dt = t. Initial conditions are given as when t = 0,
y = 10. Finally, y values against t values are graphed.

Solve dy/dt = t differential equation using matlab

syms y(t)

ode = diff(y,t) == t;

ini_con = y(0)==10;

ysol(t)= dsolve(ode,ini_con);

ezplot(ysol,[0,10]);

ode = diff(y,t) == t;

Here we define the differential equation.

Nonlinear differential equation with initial condition

Here, we are going to solve second order differential equation, [ dy/dt + y ]^{2} = 1