Effacer les filtres
Effacer les filtres

fill the 2D plot

3 vues (au cours des 30 derniers jours)
sepideh
sepideh le 12 Oct 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 commentaires
Adam Danz
Adam Danz le 12 Oct 2023
Here's your figure. Which regions do you want to fill?
sepideh
sepideh le 16 Oct 2023
Modifié(e) : sepideh le 16 Oct 2023
Thanks for your attention, I got the results

Connectez-vous pour commenter.

Réponse acceptée

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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Line Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by