Filter löschen
Filter löschen

fill the 2D plot

3 Ansichten (letzte 30 Tage)
sepideh
sepideh am 12 Okt. 2023
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 Kommentare
Adam Danz
Adam Danz am 12 Okt. 2023
Here's your figure. Which regions do you want to fill?
sepideh
sepideh am 16 Okt. 2023
Bearbeitet: sepideh am 16 Okt. 2023
Thanks for your attention, I got the results

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Sulaymon Eshkabilov
Sulaymon Eshkabilov am 12 Okt. 2023
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 Kommentare
sepideh
sepideh am 16 Okt. 2023
sure, I forgot. sorry
Sulaymon Eshkabilov
Sulaymon Eshkabilov am 16 Okt. 2023
All the best!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Line Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by