How to draw circle with radius 1 ?

6 Ansichten (letzte 30 Tage)
Eman S
Eman S am 26 Okt. 2017
Bearbeitet: Eman S am 1 Feb. 2020
My question is:
how to draw circle with radius 1 ?

Akzeptierte Antwort

KSSV
KSSV am 27 Okt. 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

Weitere Antworten (0)

Tags

Noch keine Tags eingegeben.

Community Treasure Hunt

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

Start Hunting!

Translated by