-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmatrixModel.m~
59 lines (48 loc) · 1.55 KB
/
matrixModel.m~
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
% This function is to calculate the advective flux along
% the street which produce the channeling of pollutant
% along directions to the external wind direction
function [Matrix, Matrixy, Matrixc] = matrixModel(x, y, q, w_e, B, c_0, C, ...
Q, alpha, beta, h, c)
% Represent the data in matrix form
Matrix = zeros(x - 1, y);
Matrixy = zeros(x, y - 1);
Matrixc = zeros(x,y);
% stand_dev = 1; % standard deviation of the vertical component
% U_d = (stand_dev) / sqrt(2 * pi);% transfer velocity
% Qh_turb_flux = turbulentFlux(U_d, W, L, c_0, c_E);
% Set initial boundary condtions
Matrix(1,1) = 20;
Matrixy(1,1) = 20;
c_a = alpha;
c_b = beta;
Q = 0;
for i = 1:(x)
for j = 1:(y)
% To ensure the matrix is within rage
% e.g Matrix (3x4)
if i ~= x
if j > 1
% Conditions for the top matrix
if i == 1
Matrix(i,j) = (0.5 * Q) + (c_a * Matrix(i,j-1));
else
Matrix(i,j) = (0.5 * Q) + (c_a * Matrix(i,j)) + ...
(c_b * Matrixy(i,j-1));
end
end
end
% To ensure the matrix is within rage
% e.g Matrix (4x3)
if j ~= y
if i > 1
if j == 1
Matrixy(i,j) = (0.5 * Q) + (c_b * Matrixy(i-1,j));
else
Matrixy(i,j) = (0.5 * Q) + ((1 - c_b) * Matrix(i-1,j)) + ...
((1 - c_b) * Matrixy(i,j-1));
end
end
end
end
end
end