-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCDensity1.m
67 lines (66 loc) · 2.03 KB
/
CDensity1.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
60
61
62
63
64
65
66
67
function [P] = CDensity1(time, xsols,l);
tic
%x step
s = 1/10;
%t step
S = 10;
% plot density
r = 1/4;
de = 1/4;
ep = 1/4;
lt = length(time);
n = length(xsols(1,:));
X = (0:s:2*r*n);
lx = length(X);
%pc = sqrt(6)*ones(1,lx);
%figure 1;
i=1:S:lt-1;
nlt = length(i);
P = zeros(nlt,lx);
k = 1;
for i=1:S:lt-1
for j = 1:lx
c2 = (xsols(i,:)+ep-X(j)+de).*(((xsols(i,:)-ep)<(X(j)-de)).*((xsols(i,:)+ep)>(X(j)-de)));
c3 = (2*ep)*sum(((xsols(i,:)-ep)>(X(j)-de)).*((xsols(i,:)+ep)<(X(j)-de)));
c4 = (-xsols(i,:)+ep+X(j)+de).*(((xsols(i,:)-ep)<(X(j)+de)).*((xsols(i,:)+ep)>(X(j)+de)));
P(k,j) = (1/(2*de))^1*(sum(c2)+sum(c3)+sum(c4));
end
k = k + 1;
% plot(X,P(i,:))
% %hold on
% %plot(X,pc)
% %hold off
% axis([-.1 2*r*n+.1 -.1 4])
% str = sprintf('Density at t = %i [s]',time(i));
% title({str},'FontSize',20,'FontName','Arial');
% xlabel('Location [meters]','FontSize',15,'FontName','Arial')
% ylabel('Density [people per meter]','FontSize',15,'FontName','Arial')
% dt = time(i+1)-time(i);
% pause(10^-250/dt)
% F(i) = getframe(gcf);
end
toc
contour(time(1:S:lt-1),X,P')
axis([0,max(time),0,l+0.75]);
xlabel('Time [s]','FontSize',12,'FontName','Arial')
ylabel('Location [m]','FontSize',12,'FontName','Arial')
str = sprintf('Density Plot of Dynamical Crowd System');
title({str},'FontSize',15,'FontName','Arial');
MP=max(P,[],2);
avep=mean(MP);
MAXP=max(MP);
% figure;
% hold on
% plot([1:length(MP)],MP);
% hold off
% axis([1,length(MP),0,MAXP+0.5]);
% str = sprintf('Maximum density: %i',MAXP');
% str2 = sprintf('Average Maximum density: %i',avep');
% %COMPUTATIONAL STEPS DOESNT SOUND WELL
% xlabel('Computational steps','FontSize',15,'FontName','Arial');
% ylabel('Maximum density','FontSize',15,'FontName','Arial');
% annotation('textbox', [0.05,0.00,0.1,0.1],...
% 'String',{str2},'FontSize',11);
% annotation('textbox', [0.05,0.88,0.1,0.1],...
% 'String',{str},'FontSize',11);
end