Circle Trajectory of a Mobile Beacon

In this post, we will design the circular trajectory of the mobile beacon.

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]=Circle(R,s_x,s_y) %Circular mobile trajectory
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

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

%% Mobility Model 

function[anchor_x, anchor_y]=Circle(r,node_x,node_y) 


anchor_x=[];  % Anchor trajectory
anchor_y=[];  % Anchor trajectory
idx=1;   
beacon_int=10; % Beacon broadcasting interval

for i=1:4
    switch(i)
        case 1
            R=2*pi*r;
            dif=R/beacon_int;
            th = 0:pi/dif:2*pi;
        case 2
            R=2*pi*r;
           dif=R/beacon_int;
            th = 0:pi/dif:2*pi;
        case 3
             R=2*pi*r;
            dif=R/beacon_int;
            th = 0:pi/dif:2*pi;
        case 4
             R=2*pi*r;
             dif=R/beacon_int;
             th = 0:pi/dif:2*pi;
    end

for k=1:1:length(th)
    anchor_x(1,idx) = r * cos(th(k)) + 50; 
        anchor_y(1,idx) = r * sin(th(k)) + 50;
idx=idx+1;
end
if i==4
   break;
end
for i=anchor_x(1,idx-1):5: anchor_x(1,idx-1)+15
    anchor_x(1,idx) = i; 
    anchor_y(1,idx) = anchor_y(1,1); 
    idx=idx+1;
end
    r=r+15;
end  
    sum=0;
    plot(anchor_x(1,:),anchor_y(1,:))
    hold on

for i=1:idx-1                  % Shows the 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

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

Circle trajectory of a mobile beacon

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

To get the above code, click on the below link........

https://drive.google.com/drive/folders/0B2O8tJ9QXc-3ZmdfMnFHVTlxWHc?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

Asymptotic Notations