paint the circle in half

1 回表示 (過去 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 Center および File ExchangeSurface and Mesh Plots についてさらに検索

製品


リリース

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by