How to draw circle with radius 1 ?

6 views (last 30 days)
Eman S
Eman S on 26 Oct 2017
Edited: Eman S on 1 Feb 2020
My question is:
how to draw circle with radius 1 ?

Accepted Answer

KSSV
KSSV on 27 Oct 2017
Rad3Over2 = sqrt(3) / 2;
[X Y] = meshgrid(-.2:0.2:1.6);
n = size(X,1);
X = Rad3Over2 * X;
Y = Y + repmat([0 0.5],[n,n/2]);
% Plot the hexagonal mesh, including cell borders
[XV, YV] = voronoi(X(:),Y(:));
plot(XV,YV,'b')
axis equal,
axis([.2 1.2 .2 1])
zoom on ;
hold on
%%Get centers
[V,C] = voronoin([X(:) Y(:)]) ;
xc = cellfun(@(index) mean(V(index,1)),C);
yc = cellfun(@(index) mean(V(index,2)),C);
%%draw circles
th = linspace(0,2*pi) ; r = 0.1 ;
x = r*cos(th) ; y = r*sin(th) ;
for i = 1:length(xc)
if ~isinf(xc(i))
xx = x+xc(i) ;
yy = y+yc(i) ;
plot(xx,yy,'r')
end
end

More Answers (0)

Tags

No tags entered yet.

Community Treasure Hunt

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

Start Hunting!