Set #2
"
u
1
u
2
u
3
#
=
"
0
0
0
#
for τ > 2
"
u
1
u
2
u
3
#
=
"
−0.3
−0.2
−0.1
#
for τ ≤ 2 (29)
Set #3 where control values depend on t
"
u
1
u
2
u
3
#
=
"
0
e
−t
0
#
(30)
To obtain a numerical solution, a MATLAB’s PDE
solver pdepe is used - see (MathWorks, 2002) for
details. It solves a class of parabolic/eliptic partial dif-
ferential equation (PDE) systems. The general class
to which pdepe applies has the form
c
µ
τ, t, x,
∂x
∂τ
¶
∂x
∂t
= x
−m
∂
∂τ
µ
x
m
f
µ
τ, t, x,
∂x
∂τ
¶¶
+ s
µ
τ, t, x,
∂x
∂τ
¶
(31)
where in our case 0 ≤ τ ≤ 2π and 0 ≤ t ≤ 15.
The integer m = 0 see (MathWorks, 2002) for de-
tails. The (in general) function c is a diagonal matrix
and the flux and source functions f and s are vector
valued. Initial and boundary conditions must be sup-
plied in the following form. For 0 ≤ τ ≤ 2π and
t = 0 the solution must satisfy x(t, 0) = x
0
(t) for a
specified function x
0
. For τ = 0 and 0 ≤ t ≤ 15 the
solution must satisfy
p
l
(τ, t, x) + q
l
(τ, t)f
µ
τ, t, x,
∂x
∂τ
¶
= 0 (32)
for specified functions p
l
and q
l
. Similarly for τ = 2π
and 0 ≤ t ≤ 15,
p
r
(τ, t, x) + q
r
(τ, t)f
µ
τ, t, x,
∂x
∂τ
¶
= 0 (33)
must hold for specified functions p
r
and q
r
. Below
there is a source code used in simulation of the exam-
ple (25) in the form expected by pdepe with the third
set of control inputs (30).
function [x1, x2] = cont2D
m = 0;
alpha = 2*pi;
% values at which the numerical solution is computed
% mesh points
tau = [linspace(0, alpha/2, 20)
linspace(alpha/2+0.1, alpha, 40)]; % spatial variable
t = linspace(0, 15, 40); % time variable
u = [0; 0; 0];
sol = pdepe(m,@pdefun,@pdeic,@pdebc,tau,t,[],u);
x1 = sol(:,:,1)
x2 = sol(:,:,2);
% A surface plot is often a good way to study a solution.
figure;
surf(tau, t, x1);
title(’component x_1’,’FontSize’, 12);
xlabel(’space variable tau’,’FontSize’, 12);
ylabel(’time variable t’,’FontSize’, 12);
figure;
surf(tau, t, x2);
title(’component x_2’,’FontSize’, 12);
xlabel(’space variable tau’,’FontSize’, 12)
ylabel(’time variable t’,’FontSize’, 12);
% --------------------------------------------
function [c,f,s] = pdefun(tau,t,x,DxDtau,u)
c = [1;1];
f = [0;0];
A1 = [0.7, -0.1; 0.2, -0.1];
A2 = [-0.5, 0.6; 0.7, -1.3];
B = [1, 0.2, -0.3; 0.1, 0.2, 0.3];
s = -A1*DxDtau + A2*x + B*[0; exp(-t); 0];
% --------------------------------------------
function u0 = pdeic(tau,u)
u0 = [exp(-5*(tau-1).ˆ2); sin(tau)];
% --------------------------------------------
function [pl,ql,pr,qr] = pdebc(xl,ul,xr,ur,t,u)
pl = [ul(1)-0.4; ul(2)+0.2];
ql = [0; 0];
pr = [ur(1); ur(2)];
qr = [0; 0];
The algorithm implemented in pdepe is as follow.
The routine uses a second-order spatial discretization
method based on mesh values of the spatial variable
τ. Hence the choice of them has strong influence on
the accuracy and cost of computations. The integra-
tion in time variable t is performed using ode15s
solver and hence the timestep is chosen dynamically
(MathWorks, 2002). The time t values are used only
as points where the solution is returned (and printed)
and hence have little impact on the accuracy and cost
of computations.
For example to produce Figure 5, Matlab has per-
formed calculations in 305 time points compared with
40 ones chosen by the user for plot the result of calcu-
lations. Number 305 has been obtained by analyzing
the time variable t inside the function pdefun() in