![66.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/214920/66.png)
How to draw equally sized squares
2 ビュー (過去 30 日間)
古いコメントを表示
Hi,
I draw a circle of radius 1, and I want to draw eqaully sized squares in the background of the circle. Kindly some one help,
r = 1. 0;
th = linspace(0,2*pi) ;
x = r*cos(th) ;
y = r*sin(th) ;
patch(x,y,rand(1,3)) ; % I am using random color in patch here.
axis equal
Now I want draw 10x10 squares as a background to the circle (the dia of each square is (2*r/10)).
0 件のコメント
回答 (1 件)
KALYAN ACHARJYA
2019 年 4 月 19 日
編集済み: KALYAN ACHARJYA
2019 年 4 月 19 日
x=[-1, 1, 1, -1, -1];
y=[-1, -1, 1, 1, -1];
plot(x, y, 'r-');
fill(x,y,'b')
hold on;
r=1.0;
th=linspace(0,2*pi) ;
x=r*cos(th) ;
y=r*sin(th) ;
patch(x,y,rand(1,3)) ; % I am using random color in patch here.
axis equal
![66.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/214920/66.png)
3 件のコメント
KALYAN ACHARJYA
2019 年 4 月 19 日
編集済み: KALYAN ACHARJYA
2019 年 4 月 19 日
Automatically, I dont know, but manually you can do that
x1=[-1, 1, 1, -1, -1];
y1=[-1, -1, 1, 1, -1];
plot(x1, y1, 'r-');
fill(x1,y1,'b')
% one block
hold on;
x1=[-1,-0.9,-0.9,-1,-1];
y1=[-1,-1,-0.9,-0.9,-1];
plot(x1, y1, 'y-','linewidth',2);
fill(x1,y1,'r')
![oo.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/214935/oo.png)
Keeping here blue big square for refernece purpose only
![uu.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/214933/uu.png)
参考
カテゴリ
Help Center および File Exchange で General Applications についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!