How to inser 10x10 eqaully squares in the same picture
Show older comments
I have below code to draw cirle to draw a circle, and I want to draw 10x10 squares (of eqaul size) with sum of the sides will be eqaul to cirlce dia.
pos = [2 4 2 2];
rectangle('Position',pos,'Curvature',[1 1])
axis equal
hold on
rectangle('Position',pos,'EdgeColor','r')
5 Comments
Walter Roberson
on 4 May 2019
Consider the example:
[X,Y] = ndgrid(1:10);
plot(X,Y);
hold on
plot(X.', Y.');
hold off
Mekala balaji
on 4 May 2019
Image Analyst
on 4 May 2019
The diameter of your circles is 2. If you have N squares, then the sum of the sides is N*4*width. Set that equal to the diameter, and, using simple algebra you get width = diameter/(N*4) = 0.5 * N if the diameter is 2.
Where do you want the squares?
- In a regular grid?
- Randomly placed?
- Placed in locations that you specify?
Mekala balaji
on 4 May 2019
Walter Roberson
on 4 May 2019
The size of one square is min(diff(1:10)) which is 1. That is, to use a square that is D on a side, use D as the increment, like
x_coordinates = first_x + (0:10)*D;
Answers (0)
Categories
Find more on Descriptive Statistics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!