How to draw a white circle ?

3 次查看(过去 30 天)
Hello,
I would like to draw a white circle in a black square in Matlab but I don't have any idea how to do it. Would you please explain me how to do it ?
In advance, thank you !

采纳的回答

Azzi Abdelmalek
Azzi Abdelmalek 2012-10-29
编辑:Azzi Abdelmalek 2012-10-29
r=4; %radius
x0=0;y0=0; % circle center coordinates
x=x0-r:0.01:x0+r
y=sqrt(r^2-(x-x0).^2)+y0;
fill([x0-r x0+r x0+r x0-r ],[y0-r y0-r y0+r y0+r ],'k')
hold on;
plot(x,y,'w',x,-y,'w');
axis square
axis([x0-2*r x0+2*r y0-2*r y0+2*r]) % facultative
  3 个评论
Azzi Abdelmalek
Azzi Abdelmalek 2012-10-29
Yes
fill([x fliplr(x)],[y fliplr(-y)],'w')
Azzi Abdelmalek
Azzi Abdelmalek 2012-10-29
x=x0-r:0.01:x0+r
is a vector of points we are using to plot your circle

请先登录,再进行评论。

更多回答(1 个)

Image Analyst
Image Analyst 2012-10-30
  1 个评论
K BV
K BV 2012-10-30
Thanks for the link ! I'll search in the FAQs the next time before asking any question ;)

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by