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!
0 个评论
采纳的回答
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
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)]
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!