# simulating wsn using matlab

Status
Not open for further replies.

#### pareshp

##### Newbie level 2
hi...
i am doing my thesis in wsn.i want to simulate it using matlab.so can any one please help me providing matlab code to simulate a wsn...
pattanaikparesh911@gmail.com

Last edited:

#### shahbaz.ele

##### Advanced Member level 1
what is wsn.
what type of model you need in matlab; simulink, m-file of equations etc

#### eng-

##### Newbie level 6
i want to make this psedo code for clustering the wsn and aggregate data in matlab plese any one can help me
Apply FCM algorithm to form clusters.
Each cluster c(i) contains a number of nodes, i=1, …, nc
Initially all nodes have the same amount of energy.
Code:
//cluster heads selection
maxE=zeros(1,nc) ;
maxE is a row vector contains nc zeros
it_max: maximum number of iterations
ET: is the totalnetwork energy
while(it≤it_max || ET>0)
for i = 1 to nc do
if it==1
r=rand*length(c(i))
ch(i)=c(i).r ;
else
for j=1 to length(c(i)) do
if maxE(i)<c(i).E(j)
maxE(i)=c(i).E(j)
end if
end for
ch(i)=maxE(i)
end if
end for
Calculation of distances between CHs and distances b
tween CHs and BS
for i=1 to nc
for j=1 to nc do
end for
end for
for i=1 to nc do
if dBS(i)==mindBS
ch(i) sends directly to BS
else
for j=1 to nc do
Energyif
(i≠j && d(i,j)==min(i) && dBS(i)>dBS(j))
ch(i) sends data to ch(j)
end if
end for
end if
end for
plese help me because iam very very very sad
and if one want to help me send the answer here

Last edited by a moderator:

#### eng-

##### Newbie level 6
wsn :wireless sensor network
and i need m-file in matlab
my work is :i have many nodes deploed randomlly in aregion i want to apply fuzzy c- mean clustering and divide the nodes into clusters the election of cluster head randomlly at the first round and then the election of cluster head depends on the distance betwwen nodes and QOS for each node (each node has buffer and i should find QOS for node about that buffer like BU,TH,etc) then each node in any cluster send its data to its cluster head using shortest path routing the cluster head aggregate data and then each cluster head send its data to the sink node using shortest path also. please help me if you can and i will become gratful for you ...

#### eng-

##### Newbie level 6
please any one help me in the code of fuzzy c-mean clustering the wireless sensor network in matlab but dont using the ready fcm function in matlab i want to program it
It operates into three steps. In the
first step clusters are formed by the Fuzzy C-Means method.
Each clusters contains a set of a nodes and the number of
nodes is not necessary equal in the clusters. In the second
step, a cluster head is initially elected in each cluster. Since
all nodes have the same amount of energy, a random number
is generated between 1 and the number of nodes in each
cluster and the node corresponding to this number elects
itself cluster head. This is done only at the beginning but
after a rotation mechanism based on the remaining energy is
applied to select the next cluster head. Non-cluster head
nodes send gathered data to the corresponding cluster head.

Status
Not open for further replies.