Azzera filtri
Azzera filtri

fill the 2D plot

3 visualizzazioni (ultimi 30 giorni)
sepideh
sepideh il 12 Ott 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 Commenti
Adam Danz
Adam Danz il 12 Ott 2023
Here's your figure. Which regions do you want to fill?
sepideh
sepideh il 16 Ott 2023
Modificato: sepideh il 16 Ott 2023
Thanks for your attention, I got the results

Accedi per commentare.

Risposta accettata

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

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Line Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by