How can i move one node or (n) nodes to anothor location in Each time period ?
1 view (last 30 days)
Show older comments
clear ; clc; close all;
Num_nodes = 50;
Range = 16; % Determine the transmision range.
X_position = [5 56 90 73 10 75 30 75 15 15 20 85 55 88 5 2 30 95 65 95 25 20 40 74 65 44 30 45 85 20 65 45 50 95 30 80 65 60 30 45 95 85 70 2 55 55 42 75 35 10];
Y_position = [5 25 50 70 90 85 1 25 50 70 99 95 5 25 55 80 90 85 10 34 55 80 90 5 35 56 75 99 5 40 60 75 90 15 40 60 74 93 15 40 65 75 99 20 45 65 20 45 64 30];
figure; clf ;hold on; xlabel('X-axis '); ylabel('Y-axis ');
for i = 1:Num_nodes
plot(X_position(i), Y_position(i),'o','markersize',15,'Color','m','linewidth',1);
text(X_position(i), Y_position(i), num2str(i));
axis([1,100,1,100]); % draw the nodes inside the figure
for j = 1:Num_nodes
distance_nod = sqrt((X_position(i) - X_position(j))^2 + (Y_position(i) - Y_position(j))^2);
if distance_nod <= Range && i ~= j
connection_matrix(i, j) = 1; % To know the joins between nodes according to the transmision range.
line([X_position(i) X_position(j)], [Y_position(i) Y_position(j)], 'LineStyle', '-.');
grid on;
else
connection_matrix(i, j) = inf; % There is no a link
end
end
end
How can I move a single node or a set of nodes ( in Each time period) from their current position to another location but not far from their original location, and must be that the move node connect to the node that has become within the transmission range after moving to new position.
0 Comments
Answers (1)
KSSV
on 18 Jun 2018
% selct nodes to move
movenodes = [46 26 45 40] ;
dx = 0.3; % move by this along x
dy = 0.5 ; % move by this along y
X_position(movenodes) = X_position(movenodes)+dx ;
Y_position(movenodes) = Y_position(movenodes)+dy ;
See Also
Categories
Find more on Assembly in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!