-
Notifications
You must be signed in to change notification settings - Fork 23
/
place.m
25 lines (25 loc) · 1.01 KB
/
place.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
%% Used for setting the location of target and anchor nodes in WSN
function [phi,alpha]=place(side,nNodes,nAnchors)
%Randomly place target nodes
phi=rand(2,nNodes)*side;
%Place anchor nodes at fixed locations
if nAnchors==4
alpha=[[0.25;0.25] [0.75;0.25] [0.25;0.75] [0.75;.75]]*side;
elseif nAnchors==8
alpha=[[0.25;0.25] [0.75;0.25] [0.25;0.75] [0.75;.75]...
[0;0] [1;0] [1;1] [0;1]]*side;
elseif nAnchors==12
alpha=[[0.25;0.25] [0.75;0.25] [0.25;0.75] [0.75;.75]...
[0;0] [1;0] [1;1] [0;1]...
[0;0.33] [0;0.66] [0.33;0] [0.66;0]]*side;
elseif nAnchors==16
alpha=[[0.25;0.25] [0.75;0.25] [0.25;0.75] [0.75;.75]...
[0;0] [1;0] [1;1] [0;1]...
[0;0.33] [0;0.66] [0.33;0] [0.66;0] [1;0.33] [1;0.66] [0.33;1] [0.66;1]]*side;
elseif nAnchors==20
alpha=[[0.25;0.25] [0.75;0.25] [0.25;0.75] [0.75;.75]...
[0;0] [1;0] [1;1] [0;1]...
[0;0.33] [0;0.66] [0.33;0] [0.66;0] [1;0.33] [1;0.66] [0.33;1] [0.66;1]...
[0;0.5] [0.5;0] [1;0.5] [0.5;1]]*side;
end
end