Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

Thread Subject:
wireless adhoc/sensor networks

Subject: wireless adhoc/sensor networks

From: sathish kumar

Date: 21 Dec, 2012 13:56:10

Message: 1 of 1

i want to create a wireless sensor network with 5 nodes each node has one antenna
i had written a code in MATLAB but i dont know wheather it is correct or wrong
because i am at basic level in wireless adhoc/sensor networks
please give me the basic idea or basic code in designing a network in MATLAB
my code is
noOfNodes = 50;
rand('state', 0);
hold on;
L = 1000;
R = 200; % maximum range;
netXloc = rand(1,noOfNodes)*L;
netYloc = rand(1,noOfNodes)*L;
for i = 1:noOfNodes
plot(netXloc(i), netYloc(i), '.');
text(netXloc(i), netYloc(i), num2str(i));
for j = 1:noOfNodes
distance = sqrt((netXloc(i) - netXloc(j))^2 + (netYloc(i) - netYloc(j))^2);
if distance <= R
matrix(i, j) = 1; % there is a link;
line([netXloc(i) netXloc(j)], [netYloc(i) netYloc(j)], 'LineStyle', ':');
matrix(i, j) = inf;

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us