How to fill the region formed by four lines?
1 view (last 30 days)
Show older comments
I want to fill the parallelogram region formed by four straight lines. I have tried the following codes:
beta11_um1 = @(delta11) 4.1797+0.396*delta11;
beta11_lm1 = @(delta11) 0.4090+0.396*delta11;
beta11_up1= @(delta11) 3.8058-0.475*delta11;
beta11_lp1= @(delta11) 1.916-0.475*delta11;
delta11= -10:0.1:10;
pgon1 = polyshape(delta11,beta11_um1(delta11));
pgon2 = polyshape(delta11,beta11_lm1(delta11));
pgon3= polyshape(delta11,beta11_up1(delta11));
pgon4= polyshape(delta11,beta11_lp1(delta11));
figure
plot(delta11,beta11_um1(delta11),delta11,beta11_lm1(delta11),delta11,beta11_up1(delta11),delta11,beta11_lp1(delta11));
hold on
plot(intersect(pgon1,pgon2,pgon3,pgon4),'EdgeColor','none','FaceColor','m')
The output of the codes do have the four lines plotted, but the parallelogram region in the middle is not filled. How could I fix this? Thanks!
0 Comments
Accepted Answer
David Hill
on 30 Nov 2022
Edited: David Hill
on 30 Nov 2022
beta11_um1 = @(delta11) 4.1797+0.396*delta11;
beta11_lm1 = @(delta11) 0.4090+0.396*delta11;
beta11_up1= @(delta11) 3.8058-0.475*delta11;
beta11_lp1= @(delta11) 1.916-0.475*delta11;
delta11= -10:0.1:10;
figure
plot(delta11,beta11_um1(delta11),delta11,beta11_lm1(delta11),delta11,beta11_up1(delta11),delta11,beta11_lp1(delta11));
x=[-2.598967,1.730195,3.899885,-.429277];
y=[beta11_lp1(x(1)),beta11_lp1(x(2)),beta11_up1(x(3)),beta11_up1(x(4))];
pgon=polyshape(x,y);
hold on;
plot(pgon,'EdgeColor','none','FaceColor','m')
3 Comments
David Hill
on 30 Nov 2022
beta11_um1 = @(delta11) 4.1797+0.396*delta11;
beta11_lm1 = @(delta11) 0.4090+0.396*delta11;
beta11_up1= @(delta11) 3.8058-0.475*delta11;
beta11_lp1= @(delta11) 1.916-0.475*delta11;
x=[fzero(@(x)beta11_um1(x)-beta11_lp1(x),1),...
fzero(@(x)beta11_lm1(x)-beta11_lp1(x),1),...
fzero(@(x)beta11_lm1(x)-beta11_up1(x),1),...
fzero(@(x)beta11_um1(x)-beta11_up1(x),1)]
More Answers (0)
See Also
Categories
Find more on Line Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!