필터 지우기
필터 지우기

paint the circle in half

조회 수: 3 (최근 30일)
gravy
gravy 2024년 3월 27일
댓글: Voss 2024년 3월 27일
I need to draw a circle and color the right side of it. I found how to draw a circle, but I don't know how to color half of the circle.
pos = [2 120 2 2];
rectangle('Position',pos,'Curvature',[1 1],'FaceColor',[0 .5 .5])

채택된 답변

Voss
Voss 2024년 3월 27일
편집: Voss 2024년 3월 27일
pos = [2 120 2 2];
color = [0 0.5 0.5];
r = pos(3)/2;
c = pos([1 2])+r;
th = linspace(-pi/2,3*pi/2,101); % <- use an odd number of points in linspace()
x = c(1)+r*cos(th);
y = c(2)+r*sin(th);
fill(x(1:(end+1)/2),y(1:(end+1)/2),color,'EdgeColor','none')
hold on
plot(x,y,'k')
axis equal
  댓글 수: 6
gravy
gravy 2024년 3월 27일
voss you're strong! thx
Voss
Voss 2024년 3월 27일
You're welcome!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Preprocess Data에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by