필터 지우기
필터 지우기

how to fill color in 1/4 th circle

조회 수: 3 (최근 30일)
Xiao yang
Xiao yang 2024년 6월 15일
댓글: Star Strider 2024년 6월 16일

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')

답변 (1개)

Star Strider
Star Strider 2024년 6월 15일
편집: Star Strider 2024년 6월 15일
A new function in R2024a is the polarregion function.
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];
Also see PolarAxes Properties for those details.
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)
Added second plot using the patch function.
.
  댓글 수: 10
Xiao yang
Xiao yang 2024년 6월 16일
thank you so much.
Star Strider
Star Strider 2024년 6월 16일
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

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

태그

제품


릴리스

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by