How do I connect plot points with lines using ginput?

10 ビュー (過去 30 日間)
Glenn Martinez
Glenn Martinez 2016 年 2 月 29 日
編集済み: Image Analyst 2016 年 2 月 29 日
I am trying to program a function called draw_constellation. By using ginput,the user would click on the figure and a plot point will appear. Any subsequent plot points would be connected with a line. My problem is connecting the third point with the second point and so on. Currently, the code I have only plots the first two points with a line.
Here is what I currently have:
function[] = draw_constellations
axis([0 100 0 100]);
set(gcf,'color','k');
set(gca,'color','k');
axis square;
hold on;
while 1
[x,y,button] = ginput(1);
if button == 113
break;
else
hold on
plot(x,y,'w*')
end
[xn,yn,button] = ginput(1);
plot(xn,yn,'w*');
plot([x,xn],[y,yn],'w');
end

採用された回答

David Young
David Young 2016 年 2 月 29 日
The attached function should show you how to do what you need, though you will have to modify it for your purpose.

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by