-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexplicit.m
More file actions
70 lines (40 loc) · 844 Bytes
/
explicit.m
File metadata and controls
70 lines (40 loc) · 844 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
function [Ucn] = explicit(M,N)
h = 1/(N-1);
k = 1/(M-1);
alpha = 1;
r=0.5;
xi=[0:h:1];
% CONSTRUCTION DE C
C = -2*eye(N);
for i=1:N
for j=1:N
if i == j+1 || i == j-1
C(i,j) = 1;
end
end
end
% CONSTRUCTION DE A
Aexp = eye(N) + (k/(h*h))*C;
Aimp = eye(N);
Ar = r*Aimp + (1-r)*Aexp;
% CONSTRUCTION DE B
Bexp = eye(N);
Bimp = eye(N) - (k/(h*h))*C;
Br = r*Bimp + (1-r)*Bexp;
% CONSTRUCTION DE U
U = zeros(N,M);
% CONDITION INITIALE
for i =1:N
x = (i-1)*h;
U(i,1)= (x/(2*alpha))*(x-1);
end
% CONSTRUCTION SOLUTION SCHEMA EXPLICITE
Ucn = U;
invB = inv(Br);
for j = 1:M-1
Ucn(:,j+1) = invB*Ar*Ucn(:,j);
for i = 1:M
Ucn(1,i)=0;
Ucn(N,i)=0; % CONDITIONS LIMITES
end
end