Shade an area between 5 lines

I am trying to shade this region between the 5 lines I have below(i filled it in using paint), i tried using the fill function but I dont understand how to use it for more than 2 lines.
x=linspace(-1,1);
y=linspace(-10,0);
y2 = 832.4*x-1/(14);
plot(x,y2,'b');
title('Inequalities');
hold on ;
xline(-1/4.2,'r');
yline(0,'k');
hold on ;
y3 = (3443)/(24972)+5.598041235*x;
plot(x,y3,'g');
hold on ;
y4 = 34.43018313*x-(241)/(48928);
plot(x,y4,'m');
hold on;
xlim([-0.3 0]);
ylim([-10 1]);

Respuestas (1)

Robert U
Robert U el 4 de Mzo. de 2020

1 voto

Hi tom thornton,
It's a similar question with answer.
Kind regards,
Robert

4 comentarios

tom thornton
tom thornton el 4 de Mzo. de 2020
Hi robert, thank you for the reply. I am looking at the code but I don't quite understand how to implement it into mine.
Robert U
Robert U el 4 de Mzo. de 2020
Editada: Robert U el 4 de Mzo. de 2020
You would have to find the vortices defining the border of the area to shade. Easiest way is to define boolean selections to accomplish that.
tom thornton
tom thornton el 4 de Mzo. de 2020
sorry, i dont understand what the booleans would be for me.
Robert U
Robert U el 4 de Mzo. de 2020
x=linspace(-1,1);
y=linspace(-10,0);
x1 = -1/4.2;
y1 = 0;
y2 = @(x)832.4*x-1/(14);
y3 = @(x)(3443)/(24972)+5.598041235*x;
y4 = @(x)34.43018313*x-(241)/(48928);
plot(x,y2(x),'b');
title('Inequalities');
hold on ;
xline(x1,'r');
yline(y1,'k');
plot(x,y3(x),'g');
plot(x,y4(x),'m');
xlim([-0.3 0]);
ylim([-10 1]);
v1 = [x1; y4(x1)];
v2 = [x1; min([y3(x1),y1])];
v3 = [-(3443)/(24972)/5.598041235; y1]; % y3 = 0
v4 = [1/(14)/832.4; y1]; % y2 = 0
v5 = [((241)/(48928)-1/(14))/(-832.4+34.43018313);y2(((241)/(48928)-1/(14))/(-832.4+34.43018313))]; % y4 = y2
patch('XData',[v1(1,:),v2(1,:),v3(1,:),v4(1,:),v5(1,:),v1(1,:)],'YData',[v1(2,:),v2(2,:),v3(2,:),v4(2,:),v5(2,:),v1(2,:)],'FaceAlpha',0.7,'FaceColor','red')

Iniciar sesión para comentar.

Categorías

Etiquetas

Preguntada:

el 4 de Mzo. de 2020

Comentada:

el 4 de Mzo. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by