How to connect points to create a figure?

2 ビュー (過去 30 日間)
Chris  Lambrecht
Chris Lambrecht 2015 年 11 月 9 日
回答済み: Star Strider 2015 年 11 月 9 日
I am given a figure that has points of (0,0), (0,3), and (0,4) and when connecting those points the resulting figure should be a right triangle, however, I am using scatter and lines and am only getting only two lines and an open bottom. What would be the easiest way to plot this so that the figure can be closed and I get that right triangle from the plot.

採用された回答

Star Strider
Star Strider 2015 年 11 月 9 日
I just got a straight line with the values you posted. The trick to closing the triangle is to repeat the first set of points (here (0,0)) at the end of the x and y vectors:
x = [0 0 4 0];
y = [0 3 3 0];
figure(1)
plot(x, y)
axis([-1 5 -1 5])

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by