athinap7
Newbie level 1
simulation of ad hoc network using matlab
Hi I have the following problem for my msc project.
I have to plot in Matlab a network with 15 nodes distributed randomly. Then i have to calculate the euclidean distance between the nodes and connect with a line the nodes which their distance is less than a threshold (lets say 350 m)
I have written the following code which will calculate the distance and check if it is less than 350m
for k=1:N;
for j=1:15;
if k~=j;
d(k,j)=((nodesX(k)-nodesX(j))^2+(nodesY(k)-nodesY(j))^2)^0.5;
if d<350;
line(nodesX,nodesY);
end;
end;
end;
end;
But i think that the use of the function line is wrong. How can I plot the lines between the nodes where d<350?
help pleaseeeee
Hi I have the following problem for my msc project.
I have to plot in Matlab a network with 15 nodes distributed randomly. Then i have to calculate the euclidean distance between the nodes and connect with a line the nodes which their distance is less than a threshold (lets say 350 m)
I have written the following code which will calculate the distance and check if it is less than 350m
for k=1:N;
for j=1:15;
if k~=j;
d(k,j)=((nodesX(k)-nodesX(j))^2+(nodesY(k)-nodesY(j))^2)^0.5;
if d<350;
line(nodesX,nodesY);
end;
end;
end;
end;
But i think that the use of the function line is wrong. How can I plot the lines between the nodes where d<350?
help pleaseeeee