Spiral trajectory of a mobile beacon

In this post, we will see an another mobile beacon trajectories called Spiral.

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]=Spiral(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]=Spiral(r,node_x,node_y) 
%% Mobility Model 

anchor_x=[]; % Anchor trajectory
anchor_y=[]; % Anchor trajectory
idx=1;
beacon_int=5; % Beacon broadcasting interval
t = linspace(0,12*pi,10000);
for k=1:1:length(t)
    point_x(1,k) = 50+2*t(k).*cos(t(k));
    point_y(1,k) = 50+2*t(k).*sin(t(k));
end
anchor_x(1,idx)=point_x(1,1);
anchor_y(1,idx)=point_y(1,1);
pointx=point_x(1,1);
pointy=point_y(1,1);
idx=idx+1;
len=length(point_x(1,:));
for j=1:1:len
    Find= calc_dist([pointx,pointy],[point_x(1,j),point_y(1,j)]);    
    if Find>4.8&&Find<5 .2="" span="">
        anchor_x(1,idx)=point_x(1,j);
        anchor_y(1,idx)=point_y(1,j);
        pointx=anchor_x(1,idx);
        pointy=anchor_y(1,idx);
        idx=idx+1;
    end
end
plot(point_x(1,:),point_y(1,:))
hold on

for i=1:idx-1              % shows animated output
    Ax=anchor_x(1,i);
    Ay=anchor_y(1,i);
    plot(node_x,node_y,'.');
    hold on
    plot(Ax,Ay,'r*')
    xlim([0 100])
    ylim([0 100])
    draw_circle1(Ax,Ay,r,'r')
    hold on
    pause(0.05)

end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Spiral trajectory of a mobile beacon

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

To get the above, please click on the link as given below.......

https://drive.google.com/drive/folders/0B2O8tJ9QXc-3SFhFVG05REMwMHM?usp=sharing

Comments

Popular posts from this blog

Types of Algorithm and Its Complexity Analysis

First Step of Problem Solving Using Data Structure and Algorithm

Stack Abstract Data Structure with Array Implementation