how to fill color in 1/4 th circle
3 次查看(过去 30 天)
显示 更早的评论
clear
syms x
figure
fun = sqrt(2*x-x.^2);
fplot(fun,[0,2.2]);
hold on
y1 = [0 1 0 0];
x1 = [0 1 1 0];
fill(x1,y1,'y');
hold on
x2 = 1:0.01:2;
y2 = sqrt(2*x2-x2.^2);
fill([x2,fliplr(x2)],[y2,fliplr(y2)],'r')
0 个评论
回答(1 个)
Star Strider
2024-6-15
编辑:Star Strider
2024-6-15
Try this —
figure
thetas1 = [0.5 1]*pi;
radii1 = [1 2];
polarregion(thetas1, radii1, 'FaceColor','y')
hold on
thetas2 = [0 0.5]*pi;
radii2 = [1 2];
polarregion(thetas2, radii2, 'FaceColor','r')
hold off
Ax = gca;
Ax.ThetaLim = [0 180];
Ax.RLim = [1 2];
Doing it without using any of the polar functions is also straightforward, although easier using trigonometric functions,
Try this —
r1 = 1;
th1 = linspace(0, 90);
xy1 = [1+r1*cosd(th1); 1+r1*sind(th1)];
r2 = 1;
th2 = linspace(90, 180);
xy2 = [1+r2*cosd(th2); 1+r2*sind(th2)];
figure
patch([1 xy1(1,:)], [1 xy1(2,:)], 'r', 'EdgeColor','none' )
hold on
patch([1 xy2(1,:)], [1 xy2(2,:)], 'y', 'EdgeColor','none')
hold off
axis('equal')
Ax = gca;
Ax.Visible = 0;
Make appropriate changes to get the result you want.
.
EDIT — (15 Jun 2024 at 14:38)
.
10 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Performance 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!