Plot circle in meters

1 回表示 (過去 30 日間)
Josh
Josh 2015 年 3 月 13 日
コメント済み: Brandon 2015 年 3 月 13 日
Hi,
I'm trying to plot several circles 5 meters in size within a room represented by the gird
pos = [0 0 5 5];
pos2 = [10 10 5 5];
pos3 = [20 20 5 5];
pos4 = [30 30 5 5];
rectangle('Position',pos,'Curvature',[1 1])
rectangle('Position',pos2,'Curvature',[1 1])
rectangle('Position',pos3,'Curvature',[1 1])
rectangle('Position',pos4,'Curvature',[1 1])
axis equal
axis([0 100 0 100])
I'm using the axis to represent the room size so in this case 100 meters by 100 meters. Sometimes the room size might vary say double so 200x200 and the graph then scales and everything gets smaller.
What I was hoping is everything stayed the same size but the graph grew its size rather than scale it down the fit within the small graph size
Is this possible
Thanks

回答 (1 件)

Brandon
Brandon 2015 年 3 月 13 日
Try something like this:
figure();
AX(1) = axes;
axis equal
hold('on');
set(AX(1), 'XLim', [0 100], 'YLim', [0 100]);
XC = 2.5*sin(linspace(0,2*pi,100)); YC = 2.5*cos(linspace(0,2*pi,100));
h(1) = fill(XC + 50, YC + 50, 'r'); % create circle
  2 件のコメント
Josh
Josh 2015 年 3 月 13 日
Thanks but the circle gets smaller as the grid gets bigger. Instead I was looking for a way of keeping the same circle size but instead of scaling the grid simply enlarges itself within the window
Brandon
Brandon 2015 年 3 月 13 日
You just need to express the circle size as a percentage of the room size. In this case I set the room to be 100 and the circle size to be 2.5. You can set the room size to be n and the circle size to be n/10.

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

カテゴリ

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