필터 지우기
필터 지우기

fill the 2D plot

조회 수: 3 (최근 30일)
sepideh
sepideh 2023년 10월 12일
편집: Sulaymon Eshkabilov 2023년 10월 16일
Hello
I have a plot of a two-layer fluids. I want to fill the plots with different color (lower layer red- upper layer blue)
I dont know how to use 'fill' command to do this.
would you please help me?
  댓글 수: 2
Adam Danz
Adam Danz 2023년 10월 12일
Here's your figure. Which regions do you want to fill?
sepideh
sepideh 2023년 10월 16일
편집: sepideh 2023년 10월 16일
Thanks for your attention, I got the results

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

채택된 답변

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023년 10월 12일
An easiest way would be using area() instead of plot() and patch():
v= 0.6;
r=2;
gam1= (1-v)/((r*v)-1) %for constant depth (F*=gam1=2) .here we should put a smaller gamma hence i put 1.15
gam1 = 2.0000
% TRY DIFFERENT NUMBER OF GAM RESULT IN STRANGE BEHAVIOUR
gam=1.44;
xil=(9^(2/3)*((1+gam)^(2/3)))^(1/2)
xil = 2.8003
xiu= ((v*xil^2)+((9^(2/3))*(v^(2/3))*(gam^(2/3))*((r-1)*(2/3))*((1-v)^(1/3))))^(1/2)
xiu = 2.5755
xi_star= ( ((xiu^2)-v*xil^2)/(1-v)) ^(1/2);
xi=linspace(0,xi_star,1000);
fl=@(xi) ((xiu^2-(v*xil^2))/(6*v*(r-1)))+(((v-1)*xi.^2)/(6*v*(r-1)));
fu=@(xi) (((r*v*xil^2)-xiu^2)/(6*v*(r-1)))+(((1-r*v)*xi.^2)/(6*v*(r-1)))+((xiu^2-(v*xil^2))/(6*v*(r-1)))+(((v-1)*xi.^2)/(6*v*(r-1)));
figure(2)
hold on
B =area(xi, fu(xi));
B.FaceColor = [0 0 1];
B.EdgeColor = [0 0 1];
B.LineWidth = 2;
hold on
xii=linspace(xi_star,xil);
fll=@(xii) ((xil^2-xii.^2)./(6));
C =area(xii, fll(xii));
C.FaceColor = [0 0 1];
C.EdgeColor = [0 0 1];
C.LineWidth = 2;
A =area(xi, fl(xi));
A.FaceColor = [1 0 0];
A.EdgeColor = [1 0 0];
A.LineWidth = 2;
  댓글 수: 4
sepideh
sepideh 2023년 10월 16일
sure, I forgot. sorry
Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023년 10월 16일
All the best!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by