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

TP 1 NSL

This document presents a practical simulation project on solving nonlinear Ordinary Differential Equations (ODEs) using MATLAB, aimed at enhancing understanding of nonlinear systems. It includes applications demonstrating both analytical and numerical solutions, highlighting the effectiveness of MATLAB's solvers like ode45. The findings emphasize the complexity of nonlinear dynamics and the significance of numerical methods in applied mathematics and engineering.

Uploaded by

zstmega21
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views7 pages

TP 1 NSL

This document presents a practical simulation project on solving nonlinear Ordinary Differential Equations (ODEs) using MATLAB, aimed at enhancing understanding of nonlinear systems. It includes applications demonstrating both analytical and numerical solutions, highlighting the effectiveness of MATLAB's solvers like ode45. The findings emphasize the complexity of nonlinear dynamics and the significance of numerical methods in applied mathematics and engineering.

Uploaded by

zstmega21
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Faculty of Technology, Dept.

Electrical Engineering
University August 20th,1955 of Skikda

Practical Simulation Work on Nonlinear Systems


Master_1: Automatics and industrial Informatics

PW N° 01 : Solving nonlinear Ordinary Differential


Equations (ODEs) using Matlab

Groupe 1:

• Beggour Abd rahim

• Dekali Nawfel

• Lakoui Mohamed Akram


I-Introduction :
Ordinary Differential Equations (ODEs) are fundamental tools for modeling a wide range of
phenomena in physics, biology, engineering, and economics. When these equations are nonlinear,
solving them becomes significantly more challenging, as analytical solutions are often unavailable
or extremely difficult to obtain. In such cases, numerical methods become essential. MATLAB,
with its robust suite of numerical solvers such as ode45, ode15s, and fsolve, provides an efficient
and flexible platform for solving nonlinear ODEs.
This project aims to explore various techniques for solving nonlinear ODEs using MATLAB,
illustrating the approaches through practical and representative examples. The goal is to gain a
deeper understanding of the dynamic behavior of nonlinear systems and the computational
strategies used to analyze them.

II-Application 1:
1-
syms y(t)
Dy = diff(y, t);
D2y = diff(y, t, 2);
eqn = D2y + 0.5 * Dy^2 == 1;
conds = [y(0) == 0, Dy(0) == 0];
ySol = dsolve(eqn, conds);
pretty(ySol)

-we found in command window


pi i – log( tanh(sqrt(2)÷2)2 2 - 2 ) + log(2)

2-
yt = vectorize(ySol);
t = -20:0.25:20;
yt_vals = eval(yt);
figure(1)
plot(t, yt_vals, 'b', 'LineWidth', 2)
xlabel('Temps t'), ylabel('y(t)')
title('Solution analytique de y(t)')
grid on
Solution analytique de y(t)
30

25

20
y(t)

15

10

0
-20 -15 -10 -5 0 5 10 15 20
Temps t

3-
We put :

Then the system will be:

function dxdt = nonlinear_system(t, x)


dxdt = zeros(2,1);
dxdt(1) = x(2);
dxdt(2) = 1 - 0.5 * x(2)^2;
end

4-
Tspan = -20:0.25:20;
x0 = [0 0]; % [y(0), dy(0)]
[t_num, x] = ode45(@nonlinear_system, Tspan, x0);

figure(1)
hold on
plot(t_num, x(:,1), 'r--', 'LineWidth', 2)
legend('Solution analytique', 'Solution numérique')
60
Solution analytique

50

40

30

20

10

0
-20 -15 -10 -5 0 5 10 15 20

5-

figure(2)
plot(x(:,1), x(:,2), 'm', 'LineWidth', 2)
xlabel('x_1 (y)'), ylabel('x_2 (dy/dt)')
title('Plan de phase : x_1 vs x_2')
grid on

Plan de phase : x 1 vs x 2
1.5

1
x (dy/dt)
2

0.5

0
0 10 20 30 40 50 60
x 1 (y)

6- Comments :
 The analytical solution (if explicitly found using dsolve) and the numerical solution match
closely, demonstrating the accuracy of ode45.

 The system is nonlinear and non-dissipative, so we observe an increase in velocity according to


the differential equation.

 The phase plot shows the relationship between position and velocity in the dynamic system —
it allows us to observe whether the motion is bounded, divergent, or exhibits oscillatory behavior.
III-Application 2:
1-with this state variable
x1=y
x2=dy÷dt

-we found :

function dxdt = van_der_pol(t, x, eps)


dxdt = zeros(2,1);
dxdt(1) = x(2);
dxdt(2) = -x(1) - eps * (1 - x(1)^2) * x(2);
end

2:
clc; clear; close all
eps_values = [0.1, 1, 10];
initial_conditions = [2 0; 0.2 0; 4 0];
Tspan = [0 20];

figure_index = 1;
for e = eps_values

for k = 1:size(initial_conditions, 1)
x0 = initial_conditions(k, :);

ode_fun = @(t, x) van_der_pol(t, x, e);


[t, x] = ode45(ode_fun, Tspan, x0);
figure(figure_index)
plot(x(:,1), x(:,2), 'LineWidth', 2)
xlabel('x_1 = y(t)')
ylabel('x_2 = dy/dt')
title(['Phase plot for \epsilon = ', num2str(e), ...
' and IC = [', num2str(x0(1)), ', ', num2str(x0(2)), ']'])
grid on
figure_index = figure_index + 1;
end
end

e = 0;
for k = 1:size(initial_conditions, 1)
x0 = initial_conditions(k, :);
ode_fun = @(t, x) van_der_pol(t, x, e);
[t, x] = ode45(ode_fun, Tspan, x0);

figure(figure_index)
plot(x(:,1), x(:,2), 'LineWidth', 2)
xlabel('x_1 = y(t)')
ylabel('x_2 = dy/dt')
title(['Phase plot for \epsilon = 0 and IC = [', num2str(x0(1)), ', ', num2str(x0(2)), ']'])
grid on
figure_index = figure_index + 1;
end

Phase plot for  = 0.1 and IC = [0.2, 0]


Phase plot for  = 0.1 and IC = [2, 0] 0.2
2.5
x 10
20
Phase plot for  = 0.1 and IC = [4, 0]
0
2 0.15
-2
1.5
0.1
1 -4

0.5 0.05
-6
x 2 = dy/dt

x 2 = dy/dt

0
0

x 2 = dy/dt
-8
-0.5
-0.05 -10
-1
-12
-1.5 -0.1

-2 -14
-0.15
-2.5 -16
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
x 1 = y(t) -0.2
-0.2 -0.15 -0.1 -0.05 0 0.05 0.1 0.15 0.2 -18
x 1 = y(t) -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0 0.5
x 1 = y(t) 7
x 10

Phase plot for  = 1 and IC = [0.2, 0]


0.02

0
Phase plot for  = 1 and IC = [2, 0]
3 x 10
21
Phase plot for  = 1 and IC = [4, 0]
0
-0.02
2
-1
1 -0.04

x 2 = dy/dt -2
x 2 = dy/dt

0
-0.06
-3

x 2 = dy/dt
-1

-0.08
-2
-4

-3
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
-0.1
x 1 = y(t)
-5

-0.12 -6
-0.05 0 0.05 0.1 0.15 0.2
x 1 = y(t)
-7
-3 -2.5 -2 -1.5 -1 -0.5 0 0.5
x 1 = y(t) 7
x 10

Phase plot for  = 10 and IC = [0.2, 0]


0
x 10
22
Phase plot for  = 10 and IC = [4, 0] Phase plot for  = 10 and IC = [2, 0]
-0.002 0 2

-0.004 0
-1
-0.006 -2

-2 -4
-0.008
x 2 = dy/dt

x 2 = dy/dt

-6
-0.01
-3
x 2 = dy/dt

-8
-0.012
-4 -10
-0.014
-12
-0.016 -5
-14
-0.018 -1 -0.5 0 0.5 1 1.5 2
x 1 = y(t)
-6
-0.02
0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2 0.22
x 1 = y(t) -7
-3 -2.5 -2 -1.5 -1 -0.5 0 0.5
x 1 = y(t) 7
x 10

3:
Phase plot for  = 0 and IC = [0.2, 0] Phase plot for  = 0 and IC = [4, 0]
0.2 4
Phase plot for  = 0 and IC = [2, 0]
2
0.15 3
1.5
0.1 2
1

0.05 1
0.5
x 2 = dy/dt

x 2 = dy/dt
x 2 = dy/dt

0 0 0

-0.5 -0.05 -1

-1
-0.1 -2

-1.5
-0.15 -3
-2
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
-0.2 -4
x 1 = y(t) -0.2 -0.15 -0.1 -0.05 0 0.05 0.1 0.15 0.2 -4 -3 -2 -1 0 1 2 3 4
x 1 = y(t) x 1 = y(t)
4-Comments :
Interpretation (for the final comment)

 When ε = 0 → linear system: sinusoidal periodic solutions.


 When ε > 0:
o ε = 0.1 → behavior close to the linear case.
o ε = 1 → onset of limit cycle oscillations.
o ε = 10 → relaxation oscillator: pronounced limit cycles, strongly nonlinear
behavior.

IV-Conclusion :
The study of nonlinear Ordinary Differential Equations using MATLAB highlights both the
complexity and richness of nonlinear dynamic systems. Through analytical and numerical
methods, we observed how the behavior of solutions can drastically change depending on the
system parameters, particularly the nonlinearity coefficient ε. MATLAB’s numerical solvers, such
as ode45, have proven to be highly effective for approximating solutions where analytical
expressions are difficult or impossible to obtain. By analyzing phase portraits and solution curves,
we gained valuable insights into the system's dynamics, including periodic motion, divergence,
and the emergence of limit cycles. This project underscores the importance of numerical tools in
modern applied mathematics and engineering, especially when dealing with systems that cannot be
solved analytically.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy