Draw a line between nodes which are conected.

2 次查看(过去 30 天)
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 个评论
Junaid Qadir
Junaid Qadir 2021-11-9
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

请先登录,再进行评论。

回答(1 个)

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

类别

Help CenterFile Exchange 中查找有关 Specifying Target for Graphics Output 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by