MATLAB TUTORIAL for the Second Cource. Part 3: Non-linear Systems of ODEs

Prof. Vladimir A. Dobrushkin

This tutorial contains many Matlab scripts.
You, as the user, are free to use all codes for your needs, and have the right to distribute this tutorial and refer to this tutorial as long as this tutorial is accredited appropriately. Any comments and/or contributions for this tutorial are welcome; you can send your remarks to

Email Vladimir Dobrushkin

Planar Case Case

I. Verification

function solveDifferentialEquation
%This function solves y'+y = x from starttime to endtime with y(0) = intialCondition

%Parameter initializations starttime = 0; endtime = 20; initialCondition = -2;

function yprime = DifferentialEquationFunction(x,y) yprime = y - x; end

[xVals,yVals] = ode45(@DifferentialEquationFunction,[starttime,endtime],initialCondition); plot(xVals,yVals); end %Function Complete



			%Function Complete

Example 1.1.1:

Example 1.1.2:

II. Plotting

Autonomous Systems

Consider a plane problem governed by the system of autonomous equations

\[ \dot{x} = x^2 -3\,xy, \qquad \dot{y} = 2xy-y^2 . \]
To generate plots of all solutions, we solve the autonomous system subject the same initial conditions, but on the interval {-10,10]. Actually, the whole loop corresponds to the infinite parameter interval
\( -\infty < t< \infty \)
with the point
\( (x(t), y(t) ) \)
on the trajectory approaching the origin as
\( t \mapsto \pm \infty \)
, but the finite interval
\( -10 < y 10 \)
suffices for graphical purposed.

 


function project
close all;
 
for n = -4:4
    [t,sol]=ode45(@diffeq,[0,10],[n;n]);
    plot(sol(:,1),sol(:,2))
    hold on
    [t,solu]=ode45(@diffeq,[0,-10],[n;n]);
    plot(solu(:,1),solu(:,2))
end
    X_label1 = xlabel('X');
    Y_label1 = ylabel('Y');  
    set(X_label1,'FontSize',12);
    set(Y_label1,'FontSize',12);
 
    function dwdt = diffeq(t,w)
    %x' = x^2 -3xy
    %y' = 2xy -y^2 
    %Since x = x(t) and y(t)
    %x' = x^2-3x^2=-2x^2
    %y' = 2x^2-x^2= x^2

    x1 = w(1);
    y1 = w(2);
    dx1dt = (x1)^2 -3*x1*y1;
    dy1dt = 2*x1*y1 -(y1)^2 ;
    dwdt = [dx1dt;dy1dt];
    end
end
Linearization

Enter text here

Euler Systems of Equations
Conservative Systems
Lyapunov's Second Method
Linear and Bernoulli equations
Periodic Solutions
Applications
Pendulum Equations
Van der Pol Equation
Population Models