Code covered by the BSD License  

Highlights from
TDMA basd MANET

image thumbnail

TDMA basd MANET

by

 

This file is used to analysis for TDMA based mobile ad-hoc network

[cluster_members,cluster_id]=create_cluster(number_nodes,num_transmission,xm,ym,zm)
function [cluster_members,cluster_id]=create_cluster(number_nodes,num_transmission,xm,ym,zm) 
% Writter: Pankaj Joshi India
% [cluster_members,cluster_id]=create_cluster(number_nodes,num_transmission
% ,xm,ym,zm) is return cluster members in matrix form 1st coloum of each
% raw show cluster head and remaining value of regarding row show cluster member value '0' is not a node 
% cluster id represtes row vecter containg cluster id of each cluster, for
% this function create_cluster required number of nodes in network
% (num_nodes), number of clusters (num_transmission), maximum x-cordinate
% maximum y-codinate and maximum z-cordinate (xm,ym,zm) to locate node in  
% of ground of ad-hoc network
%find of cluster heads and their location
[cluster_head,cluster_loc]=cluster_head_find(number_nodes,num_transmission,xm,ym,zm);
%%
%define cluster id for each cluster head
for k=1:num_transmission
    cluster_id(k)=k;
    cluster_members(k,1)=cluster_head(k);
end
%% Locate ordinary nodes
num_of_ord_node=number_nodes-num_transmission;
p=1;
while p<=number_nodes
    if p~=cluster_head
        [x(p),y(p),z(p)]=locate_node(xm,ym,zm);
    end
    p=p+1;
end
%% Cluster Head and Cluster Members
for l=1:number_nodes
    if (l~=cluster_head)
        for m=1:num_transmission
            dist(l,m)=distance(x(l),y(l),cluster_loc(m,1),cluster_loc(m,2));
        end
        dist_min=min(dist(l,:));
        indx=find(dist(l,:)==dist_min);
        cluster_head_c=cluster_head(indx);
        temp1=find(cluster_members(:,1)==cluster_head_c);
        temp2=length(cluster_members(temp1,:));
        cluster_members(temp1,temp2+1)=l;
    end
end
end   

Contact us