Plot circle in meters

1 visualización (últimos 30 días)
Josh
Josh el 13 de Mzo. de 2015
Comentada: Brandon el 13 de Mzo. de 2015
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

Respuestas (1)

Brandon
Brandon el 13 de Mzo. de 2015
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 comentarios
Josh
Josh el 13 de Mzo. de 2015
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 el 13 de Mzo. de 2015
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.

Iniciar sesión para comentar.

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by