-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathflowProfile.m
55 lines (44 loc) · 1.79 KB
/
flowProfile.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
function flowProfile(selectedObject, object, type, t)
% plot Nup, Ndn, Qin, Qout
% units
sec = 1;
secSymbol = 'Time (s)';
hour = 3600; % 1 hour = 3600 seconds
hourSymbol = 'Time (h)';
tNorm = t / hour;
timeUnitText = hourSymbol;
fig = figure;
fig.NumberTitle = 'off';
ax1 = subplot(2,1,1);
hold on, box off,
ax1.YGrid = 'on';
xlabel(timeUnitText), ylabel('No. of veh')
ax2 = subplot(2,1,2);
hold on, box off
xlabel(timeUnitText), ylabel('Flow (veh/s)')
switch type
case 'link'
fig.Name = ['Link ', num2str(selectedObject)];
plot(ax1, tNorm, object.Nup(selectedObject, :), 'b')
plot(ax1, tNorm, object.Ndn(selectedObject, :), 'r')
legend(ax1, 'N_{up}', 'N_{down}', 'Location', 'Best')
plot(ax2, tNorm, object.Qin(selectedObject, :), 'b')
plot(ax2, tNorm, object.Qout(selectedObject, :), 'r')
legend(ax2, 'Q_{in}', 'Q_{out}', 'Location', 'Best')
case 'source'
fig.Name = ['Source ', num2str(selectedObject), ...
' (Node ', num2str(object.nodes(selectedObject)), ')'];
plot(ax1, tNorm, object.Nup(selectedObject, :), 'b')
plot(ax1, tNorm, object.Ndn(selectedObject, :), 'r')
legend(ax1, 'N_{up}', 'N_{down}', 'Location', 'Best')
plot(ax2, tNorm, object.Qin(selectedObject, :), 'b')
plot(ax2, tNorm, object.Qout(selectedObject, :), 'r')
legend(ax2, 'Q_{in}', 'Q_{out}', 'Location', 'Best')
case 'sink'
fig.Name = ['Sink ', num2str(selectedObject), ...
' (Node ', num2str(object.nodes(selectedObject)), ')'];
plot(ax1, tNorm, object.Nup(selectedObject, :), 'b')
plot(ax2, tNorm, object.Qin(selectedObject, :), 'b')
otherwise
error('Invalid type. Accepted types: link, source, sink')
end