Shade an area between 5 lines

5 Ansichten (letzte 30 Tage)
tom thornton
tom thornton am 4 Mär. 2020
Kommentiert: Robert U am 4 Mär. 2020
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]);

Antworten (1)

Robert U
Robert U am 4 Mär. 2020
Hi tom thornton,
It's a similar question with answer.
Kind regards,
Robert
  4 Kommentare
tom thornton
tom thornton am 4 Mär. 2020
sorry, i dont understand what the booleans would be for me.
Robert U
Robert U am 4 Mär. 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')

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Graphics Object Programming finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by