0% found this document useful (0 votes)
8 views7 pages

MATLAB Report

The document provides an overview of using MATLAB to solve differential equations, highlighting its effectiveness in both numerical and symbolic solutions. It categorizes differential equations into ordinary and partial types, and presents practical examples using MATLAB functions like ode45 and dsolve. The conclusion emphasizes MATLAB's significance in engineering and scientific research for solving dynamic systems efficiently.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views7 pages

MATLAB Report

The document provides an overview of using MATLAB to solve differential equations, highlighting its effectiveness in both numerical and symbolic solutions. It categorizes differential equations into ordinary and partial types, and presents practical examples using MATLAB functions like ode45 and dsolve. The conclusion emphasizes MATLAB's significance in engineering and scientific research for solving dynamic systems efficiently.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

University of Almaaqal –

College of Engineering –
Department of Petroleum
Engineering

Differential
Equations in
MATLAB
Made by: Hussien Saaed Salim
Supervised by: Dr. Hyfaa L. Swadi
Introduction:
Differential equations are basic mathematical tools commonly
applied in most scientific and engineering disciplines to describe
changes in dynamic systems. They provide a basic framework
for explaining physical, chemical, and biological phenomena
ranging from space motion to fluid flow and heat transfer.
Advancements in computational science have enabled the
solution to differential equations using software packages, thus
deviating from analytical methods that could be cumbersome or
impossible. Of all software packages available, MATLAB is a
very effective tool for handling Ordinary Differential Equations
(ODE) and Partial Differential Equations (PDE) due to its
inbuilt functions that give effective numerical and symbolic
solutions.
The aim here is to present a complete overview of using
MATLAB to solve differential equations and to outline its vast
collection of tools, ranging from ode45 to dsolve, with
accompanying examples and graphical outputs.

1
1. A Thorough Analysis of Differential Equations
1.1 The Definition of Differential Equations
A differential equation is a mathematical equation that involves
the derivatives of a function and forms a relationship between an
independent variable and their respective derivatives. It is
usually written in the following form:
𝑭(𝒙, 𝒚, 𝒚′ , 𝒚′′ , … . 𝒚𝒏 ) = 𝟎
where:
𝒙: operates as a free variable.
𝒚: denotes an unspecified function.
𝒚′ , 𝒚′′ , … . 𝒚𝒏 : are the derivatives of 𝑦

1.2 Categorization of Differential Equations


Differential equations can be divided into different
classifications, most important among which are:
• Ordinary Differential Equations (ODEs) include
derivatives that have a single independent variable.
• Partial Differential Equations (PDEs) include derivatives
in multiple independent variables.
• Linear and Nonlinear Equations: An equation is linear
when it contains constant coefficients and is in a form in
which both the function and derivatives are restricted to a
first degree; in all other cases, however, the equation is
nonlinear.

1.3 Practical Uses Differential equations


They have important applications in numerous fields, such as:
Engineering: Analyzing electrical and mechanical systems.
Physics: Investigating Classical Mechanics and
2
Thermodynamics principles. Biology: Modeling disease spread
and drug interactions. Economics: Examining economic growth
models.

2. Employing MATLAB in Solving Differential


Equations
MATLAB provides a range of tools for solving differential
equations, which can be divided into two main types of
solutions:

2.1 Computational Method


MATLAB utilizes numerical methods to solve ordinary
differential equations, such as:
• ode45 employs a Runge-Kutta method, which is suited for
most applications.
• ode23: Appropriate for problems requiring lower accuracy
but with greater speed.
• ode15s: Employed to solve stiff equations.

2.2 Symbolic Resolution


The dsolve function is used to find an analytical (symbolic)
solution for a differential equation.

3
3. Practical Examples in MATLAB
3.1 Solving an Ordinary Differential Equation Using ode45
We aim to solve the following differential equation:
𝑑𝑦
= −2𝑦, 𝑦(0) = 1
𝑑𝑥
MATLAB code:
function dydx = myODE(x, y)
dydx = -2 * y;
end
x_span = [0 5]; % Solution range from 0 to 5
y0 = 1; % Initial condition
[x, y] = ode45(@myODE, x_span, y0);
plot(x, y, 'r', 'LineWidth', 2)
xlabel('x')
ylabel('y')
title('Solution of Differential Equation using
ode45')
grid on

Results Analysis:

The implementation produces a decreasing exponential curve,


which is proof for the equation solution. This result confirms
that the solution is correct, as the analytical solution to the
equation is:
𝑦(𝑥 ) = 𝑒 −2𝑥

4
3.2 Solving a System of Differential Equations
Using ode45 consider solving the following system:
𝑑𝑥 𝑑𝑦
= 𝑦, = −𝑥
𝑑𝑡 𝑑𝑡

MATLAB code:
function dydt = mySystem(t, Y)
dydt = [Y(2); -Y(1)];
end
t_span = [0 10];
Y0 = [1; 0];
[t, Y] = ode45(@mySystem, t_span, Y0);
plot(t, Y(:,1), 'b', t, Y(:,2), 'r')
legend('x(t)', 'y(t)')
xlabel('t')
ylabel('Values')
title('Solution of a System of Differential
Equations')
grid on

Results Analysis
The solution appears as a simple harmonic motion, which is
expected since this system represents sinusoidal oscillations
similar to the motion of a simple pendulum.

4. Examination and Interpretation of Results

The preceding illustrations showed how to solve ordinary


differential equations using MATLAB. The ode45 function
proved to be effective in producing accurate numerical
approximations. Visual representations were utilized to enable
the examination of solutions and hence provide insight into
behavior in dynamic systems.

5
Conclusion
MATLAB is commonly known to be an extremely effective and
very powerful software for computing used extensively and
extensively in a variety of fields for the solution to differential
equations using both symbolic and numerical approaches. This
is a very impressive ability that allows engineers and scientists
to solve dynamic systems with unprecedented speed and
efficacy in the field, making MATLAB a highly useful and
indispensable tool in scientific research and in a wide variety of
different fields in engineering.

References
1. Chapra, S. C., & Canale, R. P. (2015). Numerical Methods
for Engineers. McGraw-Hill Education.
2. MATLAB Documentation -
https://www.mathworks.com/help/matlab/
3. Kreyszig, E. (2011). Advanced Engineering Mathematics.
Wiley.

You might also like