change the ploted node location every 1 second

suppose i plot some nodes on the graph and i wish to change the node location every second .
node=20;
area=100;
X=rand(1,node)*area;
Y=rand(1,node)*area;
for i=1:node
plot(X(i),Y(i));
text(X(i),Y(i),num2str(i));
end

 採用された回答

Geoff Hayes
Geoff Hayes 2015 年 4 月 19 日

0 投票

Singh - if you want to change the location of the kth node, then consider keeping an array of handles to each of the graphics objects returned by plot and text so that you can change the data (position of the node) at will. For example,
figure;
hold on;
node=20;
area=100;
X=rand(1,node)*area;
Y=rand(1,node)*area;
hPlots = [];
hTexts = [];
for k=1:node
hPlots(k) = plot(X(k),Y(k));
hTexts(k) = text(X(k),Y(k),num2str(k));
end
Now change the 4th node position by doing the following
set(hPlots(4),'XData', 10, 'YData',10);
set(hTexts(4),'Position', [10 10 0]);
Try the above and see what happens!

5 件のコメント

singh
singh 2015 年 4 月 19 日
thanks
But Geoff Hayes,I wish all node location will be change every second and it is not change manually
Geoff Hayes
Geoff Hayes 2015 年 4 月 19 日
How do the node positions change if not manually? Or do you have an algorithm that does this for you?
singh
singh 2015 年 4 月 21 日
Geoff Hayes, I have some solution to change location of each node every second but i am confused with this code can you solve this solution. if yes,then send me your mail ill be send you code.
singh
singh 2015 年 4 月 21 日
Geoff hayes, i have some code which change the location but i did not get good result because code is so confuse. if u can help me plz send ur email id
Geoff Hayes
Geoff Hayes 2015 年 4 月 22 日
Singh - please post the code that you have written and describe the problems that you are observing with it.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLine Plots についてさらに検索

質問済み:

2015 年 4 月 19 日

コメント済み:

2015 年 4 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by