Hilbert trajectory of a mobile beacon
In this post, we will design an another mobile trajectory called Hilbert.
clc
clear all
close all
%% Deployment of the nodes and anchor nodes
N=100; % Total Number of Sensors
A=10; % Total Number of Anchors
X=100; % Area length
Y=100; % Area width
R=10; % Transmission radius (m)
[s_x,s_y]=create_distribution(N,X,Y); %Static sensors random distribution
plot(s_x,s_y,'bo'); % plot the sensor distribution
hold on
[a_x,a_y]=Hilbert(R,s_x,s_y)
plot(a_x,a_y,'mo'); % plot the anchor distribution
grid on
hold on
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Create Distribution Function (Create a new file and paste the below code and saved the file as create_distribution.m)
function[s_x,s_y]=create_distribution(N,X,Y)
s_x = rand(1,N)*X; % Sensor random distribution of X axis
s_y = rand(1,N)*Y; % Sensor random distribution of Y axis
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function[anchor_x, anchor_y]=Hilbert(r,node_x,node_y)
%% Mobility Model
anchor_x=[];% Anchor trajectory
anchor_y=[];% Anchor trajectory
%% Network Setup
A = zeros(0,2);
B = zeros(0,2);
C = zeros(0,2);
D = zeros(0,2);
north = [ 0 7];
east = [ 7 0];
south = [ 0 -7];
west = [-7 0];
order = 4;
for n = 1:order
AA = [B ; north ; A ; east ; A ; south ; C];
BB = [A ; east ; B ; north ; B ; west ; D];
CC = [D ; west ; C ; south ; C ; east ; A];
DD = [C ; south ; D ; west ; D ; north ; B];
A = AA;
B = BB;
C = CC;
D = DD;
end
A = [0 0; cumsum(A)];
plot(A(:,1),A(:,2))
hold on
anchor_x(1,:)=A(:,1)';
anchor_y(1,:)=A(:,2)';
idx=length(anchor_x(1,:));
for i=1:idx
% Plot network trajectory
Ax=anchor_x(1,i);
Ay=anchor_y(1,i);
plot(node_x,node_y,'.');
hold on
plot(Ax,Ay,'r*')
pause(0.05)
xlim([0 100])
ylim([0 100])
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
To get a this code, link is given below........
https://drive.google.com/drive/folders/0B2O8tJ9QXc-3UVNPMUtYUXVCeGc?usp=sharing
clc
clear all
close all
%% Deployment of the nodes and anchor nodes
N=100; % Total Number of Sensors
A=10; % Total Number of Anchors
X=100; % Area length
Y=100; % Area width
R=10; % Transmission radius (m)
[s_x,s_y]=create_distribution(N,X,Y); %Static sensors random distribution
plot(s_x,s_y,'bo'); % plot the sensor distribution
hold on
[a_x,a_y]=Hilbert(R,s_x,s_y)
plot(a_x,a_y,'mo'); % plot the anchor distribution
grid on
hold on
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Create Distribution Function (Create a new file and paste the below code and saved the file as create_distribution.m)
function[s_x,s_y]=create_distribution(N,X,Y)
s_x = rand(1,N)*X; % Sensor random distribution of X axis
s_y = rand(1,N)*Y; % Sensor random distribution of Y axis
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function[anchor_x, anchor_y]=Hilbert(r,node_x,node_y)
%% Mobility Model
anchor_x=[];% Anchor trajectory
anchor_y=[];% Anchor trajectory
%% Network Setup
A = zeros(0,2);
B = zeros(0,2);
C = zeros(0,2);
D = zeros(0,2);
north = [ 0 7];
east = [ 7 0];
south = [ 0 -7];
west = [-7 0];
order = 4;
for n = 1:order
AA = [B ; north ; A ; east ; A ; south ; C];
BB = [A ; east ; B ; north ; B ; west ; D];
CC = [D ; west ; C ; south ; C ; east ; A];
DD = [C ; south ; D ; west ; D ; north ; B];
A = AA;
B = BB;
C = CC;
D = DD;
end
A = [0 0; cumsum(A)];
plot(A(:,1),A(:,2))
hold on
anchor_x(1,:)=A(:,1)';
anchor_y(1,:)=A(:,2)';
idx=length(anchor_x(1,:));
for i=1:idx
% Plot network trajectory
Ax=anchor_x(1,i);
Ay=anchor_y(1,i);
plot(node_x,node_y,'.');
hold on
plot(Ax,Ay,'r*')
pause(0.05)
xlim([0 100])
ylim([0 100])
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Hilbert trajectory of a mobile beacon |
To get a this code, link is given below........
https://drive.google.com/drive/folders/0B2O8tJ9QXc-3UVNPMUtYUXVCeGc?usp=sharing
Comments
Post a Comment