function [agentCoord, doorCoord, wallCoord, pileCoord, prefDoor, doorFam,...
v, rad, doorW, xmax, ymax] = init5(xmax, ymax, nrPeople, doorW,...
distToCorner, pileNr, pileDist)
% This function creates a room with doors and piles
% The doors are specified in a CSV file called "doors.csv"
% The piles are specified in a CSV file called "piles.csv"
%
% INPUT:
% xmax, ymax ... the dimensions of the room
% nrPeople ... how many people it will have in the room
% doorW ... has no further use anymore
% distToCorner ... has no further use anymore
% pileNr ... has no further use anymore
% pileDist ... has no further use anymore
%
% OUTPUT:
% agentCoord ... The coordinates of the people.
% doorCoord ... The coordinates of the doors (i.e. the middle of the door)
% wallCoord ... The coordinates of the wall-"people". These are particles,
% which don't move, thus represent wall-elements.
% This matrix also contains the coordinates of the piles in
% the first column
% pileCoord ... The explicit coordinates of the piles (middle of the pile)
% prefDoor ... This gives the currently prefered door of the people, it's
% a vector with one entry for each person in agentCoord. The
% index of the value corresponds to the person with the same
% index in the matrix agentCoord
% doorFam ... Stores information about every agent. Tells us which doors
% an agent is familiar to.
% v ... These should be the initial velocities of the people. It
% should have the same size as agentCoord.
% rad ... This gives how big persons are.
% doorW ... For each Door, we need to know its size.
% xmax, ymax ... The dimensions of the room.
%% Parameters
% some parameters for the doors
Deps = 0;
fak = 2;
% the distance between two wall elements
Weps = 0.1;
% the size of the people
peopleRad = 0.75;
%% the room
% boarder walls
piles = [];
% get coordinates from CSV file
doors = csvread('doors.csv');
%piles = csvread('piles.csv');
% the full walls
% the construction of the north wall
northWall = 0:Weps:xmax;
northWall = northWall(:);
northWall = [northWall, ymax * ones(size(northWall))];
% the construction of the east wall
eastWall = 0:Weps:ymax;
eastWall = eastWall(:);
eastWall = [xmax * ones(size(eastWall)), eastWall];
% the construction of the south wall
southWall = 0:Weps:xmax;
southWall = southWall(:);
southWall = [southWall, 0 * ones(size(southWall)) ];
% the construction of the west wall
westWall = 0:Weps:ymax;
westWall = westWall(:);
westWall = [0 * ones(size(westWall)), westWall];
% place doors into wall
% hold door widths (capacities)
doorW = [];
% hold door coordinates
doorCoord = [];
% loop through all doors
for i=1:size(doors, 1)
% position
cDoorX = doors(i, 1);
cDoorY = doors(i, 2);
% capacity
cDoorW = doors(i, 3);
if cDoorX == 0
% west wall
startY = (cDoorY - (cDoorW / 2));
endY = (cDoorY + (cDoorW / 2));
% cut the door out of the wall
westWall = [westWall(1:(startY/Weps),:);...
westWall((endY/Weps):size(westWall),:)];
end
if cDoorX == xmax
% east wall
startY = (cDoorY - (cDoorW / 2));
endY = (cDoorY + (cDoorW / 2));
% cut the door out of the wall
eastWall = [eastWall(1:(startY/Weps),:);...
eastWall((endY/Weps):size(eastWall),:)];
end
if cDoorY == 0
% south wall
startX = (cDoorX - (cDoorW / 2));
endX = (cDoorX + (cDoorW / 2));
% cut the door out of the wall
southWall = [southWall(1:(startX/Weps),:);...
southWall((endX/Weps):size(southWall),:)];
end
if cDoorY == ymax
% north wall
startX = (cDoorX - (cDoorW / 2));
endX = (cDoorX + (cDoorW / 2));
% cut the door out of the wall
northWall = [northWall(1:(startX/Weps),:);...
northWall((endX/Weps):size(northWall),:)];
end
% add door to the door coordinates container
doorCoord(i,1) = cDoorX;
doorCoord(i,2) = cDoorY;
doorW(i) = cDoorW;
end
% init pile coordinates
pileCoord = [];
% loop through all piles
for i=1:size(piles, 1)
% coordinates
cPileX = piles(i, 1);
cPileY = piles(i, 2);
% pile width (default 1)
cPileW = 1;
startX = (cPileX - (cPileW / 2));
endX = (cPileX + (cPileW / 2));
startY = cPileY - (cPileW / 2);
endY = cPileY + (cPileW / 2);
% x and y coordinates of the pile
pileCoordX = [];
pileCoordY = [];
% cut pile into small piles (Weps)
for k=startY:Weps:endY
% store coordinates of current pile
pileCoordX = [startX:Weps:endX];
pileCoordX = pileCoordX(:);
% calculate Y coordinates
pileCoordY = k * ones(size(pileCoordX));
% append to other piles
pileCoord = [pileCoord;[pileCoordX, pileCoordY]];
end
end
% put the walls and piles together
wallCoord = [pileCoord;northWall; southWall; westWall; eastWall];
%% People
% place the people
%agentCoord = rand(nrPeople,2) .* repmat([xmax, ymax],nrPeople, 1);
% ensure no agent will be placed inside of a pile
agentCoord = [];
i = 1;
while i <= nrPeople
% random coordinates
agentCX = rand() * xmax;
agentCY = rand() * ymax;
% position is ok by default
coordOk = true;
% loop through walls and piles
for k=1:size(wallCoord,1)
if abs(wallCoord(k,1)-agentCX) <= peopleRad &&...
abs(wallCoord(k,2)-agentCY) <= peopleRad
% to close to a wall or pile, retry
coordOk = false;
break;
end
end
if coordOk == false
% to close, retry
continue;
else
% coordinates ok, store
agentCoord(i,1) = agentCX;
agentCoord(i,2) = agentCY;
i = i + 1;
end
end
% set random door preferences
prefDoor = ceil(rand(nrPeople,1) .* size(doorCoord,1));
% setup random door acknowledges
doorFam = [];
for i=1:nrPeople
for j=1:size(doorCoord,1)
doorFam(i,j) = round(rand());
end
end
% test if the people have chosen a valid door
for i = 1:nrPeople
while (doorW(prefDoor(i)) == 0)
prefDoor(i) = ceil(rand(1) * length(doorW));
end
end
% set value and direction of the initial velocities
% of the people
rad = peopleRad * ones(nrPeople,1);
v = zeros(nrPeople, 2);
for i = 1:nrPeople
dir = doorCoord(prefDoor(i),:) - agentCoord(i,:);
v(i,:) = (dir./norm([xmax,ymax])) * norm([15,15]);
end
没有合适的资源?快使用搜索试试~ 我知道了~
公共场所人员分类疏散matlab模拟仿真+仿真录像
共29个文件
m:21个
jpg:3个
csv:3个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 1 下载量 121 浏览量
2022-10-24
00:37:13
上传
评论
收藏 11.29MB RAR 举报
温馨提示
1.版本:matlab2021a,我录制了仿真操作录像,可以跟着操作出仿真结果 2.领域:人员分类疏散 3.内容:公共场所人员分类疏散matlab模拟仿真,设置了三个不同的出口,不同人员各自往不同的出口疏散。 4.适合人群:本,硕等教研学习使用
资源推荐
资源详情
资源评论
收起资源包目录
公共场所人员分类疏散matlab模拟仿真.rar (29个子文件)
公共场所人员分类疏散matlab模拟仿真
操作录像0033.avi 24.56MB
matlab
main.m 499B
walls.csv 993B
runTimesDiffPileDist 1KB
doors.csv 18B
func
potDoor.m 1KB
force.m 2KB
is_fam.m 452B
init3.m 4KB
potWall.m 296B
basic2.m 4KB
is_vis.m 2KB
plotField.m 2KB
init2.m 3KB
distance.m 185B
init1.m 4KB
distance_time.m 156B
potAgent.m 314B
init4.m 4KB
init5.m 6KB
plotStats.m 4KB
start.m 634B
debug.m 1KB
get_queue_count.m 1KB
simulation.m 6KB
piles.csv 11B
33.jpg 27KB
221.jpg 19KB
12.jpg 34KB
共 29 条
- 1
资源评论
- zhoucongdemei2023-02-20支持这个资源,内容详细,主要是能解决当下的问题,感谢大佬分享~
fpga和matlab
- 粉丝: 16w+
- 资源: 2558
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功