vidya.patil1990
Newbie level 1
- Joined
- May 23, 2013
- Messages
- 1
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,291
Hey guys,
I am a post graduate student and I am working on wsn as a field of interest. I am a beginner so learning to code in Matlab.
Initially In my project i need to generate a sensor network (I have considered 50 nodes). cluster them uniformly(5 clusters ,with 10 sensor nodes including CH).
all CH's placed in the center .The code which im upto till now is not meeting my requirements.Can someone pls help me in doing this.. ?
clear;
xmax=100;
ymax=100;
n=50;
%Generation of sensor nodes
for i=1:1:n;
rand('state', 0);
XR=rand(1,n)*xmax; %structure array of x and y coordinates of a node and node id
YR=rand(1,n)*ymax;
if (XR(i)>25 && XR(i)<75 && YR(i)>25 && YR(i)<75)
N(i).level=0;
plot(XR(i),YR(i),'*r') %plot CHs in middle
text(XR(i),YR(i), num2str(i));
axis([0 100 0 100])
hold on; %to display all the CH in the area ranging from 25 to 75
else
N(i).level=1;
plot(XR(i),YR(i),'*g')
text(XR(i),YR(i), num2str(i));
axis([0 100 0 100])
end
end
I am a post graduate student and I am working on wsn as a field of interest. I am a beginner so learning to code in Matlab.
Initially In my project i need to generate a sensor network (I have considered 50 nodes). cluster them uniformly(5 clusters ,with 10 sensor nodes including CH).
all CH's placed in the center .The code which im upto till now is not meeting my requirements.Can someone pls help me in doing this.. ?
clear;
xmax=100;
ymax=100;
n=50;
%Generation of sensor nodes
for i=1:1:n;
rand('state', 0);
XR=rand(1,n)*xmax; %structure array of x and y coordinates of a node and node id
YR=rand(1,n)*ymax;
if (XR(i)>25 && XR(i)<75 && YR(i)>25 && YR(i)<75)
N(i).level=0;
plot(XR(i),YR(i),'*r') %plot CHs in middle
text(XR(i),YR(i), num2str(i));
axis([0 100 0 100])
hold on; %to display all the CH in the area ranging from 25 to 75
else
N(i).level=1;
plot(XR(i),YR(i),'*g')
text(XR(i),YR(i), num2str(i));
axis([0 100 0 100])
end
end