5x4 colored circle in a grid format
이전 댓글 표시
Hello,
How do I create a 5x4 circles in a grid formate with specific circles having different colors
답변 (1개)
KSSV
2021년 7월 7일
th = linspace(0,2*pi) ;
r = 0.1 ;
xc = r*cos(th) ;
yc = r*sin(th) ;
x = 1:5 ;
y = 1:4 ;
[X,Y] = meshgrid(x,y) ;
figure
hold on
for i = 1:4
for j = 1:5
patch(X(i,j)+xc,Y(i,j)+yc,rand(1,3))
end
end
Or
th = linspace(0,2*pi) ;
r = 0.1 ;
xc = r*cos(th) ;
yc = r*sin(th) ;
x = 1:5 ;
y = 1:4 ;
[X,Y] = meshgrid(x,y) ;
c = sqrt(X.^2+Y.^2) ;
scatter(X(:),Y(:),100,c(:),'filled')
카테고리
도움말 센터 및 File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!