Borrar filtros
Borrar filtros

fill the 2D plot

3 visualizaciones (últimos 30 días)
sepideh
sepideh el 12 de Oct. de 2023
Editada: Sulaymon Eshkabilov el 16 de Oct. de 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 comentarios
Adam Danz
Adam Danz el 12 de Oct. de 2023
Here's your figure. Which regions do you want to fill?
sepideh
sepideh el 16 de Oct. de 2023
Editada: sepideh el 16 de Oct. de 2023
Thanks for your attention, I got the results

Iniciar sesión para comentar.

Respuesta aceptada

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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by