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

 채택된 답변

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

Hi,i just wanted to know how do i change the colour of the text to white?
text(x, y, caption, 'Color', 'w');
Yashlin Naidoo
Yashlin Naidoo 2015년 5월 20일
편집: Yashlin Naidoo 2015년 5월 20일
Hi there,i wanted to know how do i just add the area value in the text instead of area=value
Just remove the "Area = " when you call sprintf():
caption = sprintf('%.1f', area);
Hi there,i wanted to know how do i save an axis as a image automatically?
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');
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개)

카테고리

도움말 센터File Exchange에서 Axis Labels에 대해 자세히 알아보기

질문:

2015년 5월 19일

편집:

2015년 5월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by