Draw a line between nodes which are conected.

2 vues (au cours des 30 derniers jours)
priyanka
priyanka le 26 Nov 2014
num1 = input('Enter the no of nodes you want to consider in your WSN');
radius = 30;
i=num1;
Adj = zeros(i,i);
for i= 1:num1
X = randi([0 200],1,num1);
Y = randi([0 200],1,num1);
end
X
Y
plot(X1,Y1,'gx','LineWidth',4,'MarkerSize',15)
can we give numbering to nodes and create a line to show that they are connected. Let assume all nodea are connected
  1 commentaire
Junaid Qadir
Junaid Qadir le 9 Nov 2021
Find the attached code below
total_number_of_nodes = 10;
for i=1:1:total_number_of_nodes
S(i).xd=rand(1,1)*500;
S(i).yd=rand(1,1)*500;
S(i).ID=i;
plot3(S(i).xd,S(i).yd, 0 ,'mo',... % Plot all the nodes in 3 dimension
'LineWidth',1.5,... % Size of the line
'MarkerEdgeColor','k',... % The color of the outer surface of the node. Currently it is set to black color. "k" stand for black.
'MarkerFaceColor',[1 1 0],... % The color of the inside of the node. Currently it is set to yellow color. "[1 1 0]" is a code of yellow color
'MarkerSize',10), ...
box on
xlabel(' Length (m)') % X-label of the output plot
ylabel(' Width (m)') % Y-label of the output plot
zlabel(' Height (m)') % Z-label of the output plot
title(' Random deployment of the sensor nodes in the network') % Title of the plot
grid on % Activate the grid in background of the plot
% Hold figure 1
hold on
text(S(i).xd+0.01, S(i).yd+0.01, 0+0.01,["Node", num2str(i)]); % To show ID number of each node
end

Connectez-vous pour commenter.

Réponses (1)

Junaid Qadir
Junaid Qadir le 9 Nov 2021
Also refer to the link below
https://it.mathworks.com/matlabcentral/fileexchange/99609-how-to-deploy-sensor-nodes-in-wireless-sensor-network-3d

Catégories

En savoir plus sur Graphics dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by