How do i insert the area of each shape in the centre of it?

2 ビュー (過去 30 日間)
Yashlin Naidoo
Yashlin Naidoo 2015 年 5 月 19 日
編集済み: Yashlin Naidoo 2015 年 5 月 30 日
This is my code below :

採用された回答

Image Analyst
Image Analyst 2015 年 5 月 19 日
Use sprintf() to create a string with the area in it. Then use text() to place it in the axes
caption = sprintf('Area = %.1f', area);
text(x, y, caption);
Of course you need to figure out what x and y are to position the string in the best looking spot.
  8 件のコメント
Yashlin Naidoo
Yashlin Naidoo 2015 年 5 月 25 日
How to draw every type of triangle?
I was only able to generate a equilateral triangle with my code below;
%Triangle=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
sides = 3;
t = (1/(2*sides):1/(sides):1)*2*pi-pi/3;
b = User_input(3);
x = b*sin(t)+5/8*xmax;
y = b*cos(t)+3/4*ymax;
fill(x,y,'black');
Image Analyst
Image Analyst 2015 年 5 月 25 日
Not sure what you mean. To get every triangle, or just any triangle in general, you have to make the x and y have the coordinates of the three vertices. But I'm sure you know that already , so I'm not really sure what the question is.

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by