How to fill the region formed by four lines?

6 次查看(过去 30 天)
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!

采纳的回答

David Hill
David Hill 2022-11-30
编辑:David Hill 2022-11-30
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 个评论
David Hill
David Hill 2022-11-30
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)]
x = 1×4
-2.5990 1.7302 3.8999 -0.4293
Tmat
Tmat 2022-11-30
@David Hill Thanks, David! This is very helpful. One last question: how to show the legends of these equations on the graph too?

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by