How to move a point in 2d grid

3 ビュー (過去 30 日間)
Muhammad Abrar Akber
Muhammad Abrar Akber 2014 年 5 月 17 日
I intend to move a point (say 0,0) in 2-D grid to the desired positions(say (5,5) (10,5), (50, 50) etc, Furthermore the point should move to new position with some delay according to distance between source and destination location. How it will be accomplished?

回答 (1 件)

Image Analyst
Image Analyst 2014 年 5 月 17 日
Try this:
clc;
workspace;
close all;
points = [0,0;
5,5;
10,5;
50, 50]
minX = min(points(:,1))-1;
maxX = max(points(:,1)) + 1;
minY = min(points(:,2))-1;
maxY = max(points(:,2)) + 1;
for k = 1 : size(points, 1)
fprintf('Plotting (%d, %d)\n', points(k,1), points(k, 2));
plot(points(k,1), points(k, 2), 'b*', ...
'MarkerSize', 10, 'LineWidth', 3);
grid on;
xlim([minX, maxX]);
ylim([minY, maxY]);
pause(1);
end
msgbox('Done with demo');
  1 件のコメント
Muhammad Abrar Akber
Muhammad Abrar Akber 2014 年 5 月 17 日
Thank you very much for your kind answer. It was very helpful for me. I require that the point should move with random delay based upon the distance between the source and destination node. i.e the speed of node will be different for each node (depending upon the distance between the node)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeAnimation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by