How can I create a circle in the middle of the figure which do not touch axis..??

2 ビュー (過去 30 日間)
zarana
zarana 2014 年 11 月 20 日
回答済み: David Young 2014 年 11 月 20 日
I am trying to simulate following code..
x=2;
y=2;
r=3;
ang=0:0.01:2*pi;
xp=r*cos(ang);
yp=r*sin(ang);
plot(x+xp,y+yp);
but in this code circle toch the edges..i want a circle which is in middle..how can i do it

回答 (3 件)

Star Strider
Star Strider 2014 年 11 月 20 日
This works:
x=2;
y=2;
r=3;
ang=0:0.01:2*pi;
xp=r*cos(ang);
yp=r*sin(ang);
plot(x+xp,y+yp);
axis([min(x+xp)-1 max(x+xp)+1 min(y+yp)-1 max(y+yp)+1])
axis square
You can use the axis function to set the limits and other properties of your figure axis.

Chad Greene
Chad Greene 2014 年 11 月 20 日
Follow it with this:
axis([-2 6 -2 6])
axis equal
The first line sets limits of the axes, the second line ensures that the circle isn't squashed.

David Young
David Young 2014 年 11 月 20 日
Try adding
margin = 2; % how much space to leave
axis([x x y y] + [-1 1 -1 1]*(r+margin));

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by