フィルターのクリア

I want to colour the area between red line and black line below the intersection point. how am i going to do it?

1 回表示 (過去 30 日間)
I want to colour the area between red line and black line below the intersection point. how am i going to do it?
c=[3,5];
A=[1,2;1,1;0,1];
b=[2000;1500;600];
y1=0:1:max(b);
x21=(b(1)-A(1,1)*y1)./A(1,2);
x22=(b(2)-A(2,1)*y1)./A(2,2);
x23=(b(3)-A(3,1)*y1)./A(3,2);
plot(y1,x21,'r',y1,x22,'k',y1,x23,'b');

回答 (2 件)

Chunru
Chunru 2021 年 11 月 28 日
c=[3,5];
A=[1,2;1,1;0,1];
b=[2000;1500;600];
y1=0:1:max(b);
x21=(b(1)-A(1,1)*y1)./A(1,2);
x22=(b(2)-A(2,1)*y1)./A(2,2);
x23=(b(3)-A(3,1)*y1)./A(3,2);
plot(y1,x21,'r',y1,x22,'k',y1,x23,'b');
hold on
fill( [y1(end:-1:993)'; y1(993:end)'; ], [x22(end:-1:993)'; x21(993:end)'], 'y' )

Star Strider
Star Strider 2021 年 11 月 28 日
Use ‘logical indexing’ to identify & fill the appropriate area —
c=[3,5];
A=[1,2;1,1;0,1];
b=[2000;1500;600];
y1=0:1:max(b);
x21=(b(1)-A(1,1)*y1)./A(1,2);
x22=(b(2)-A(2,1)*y1)./A(2,2);
x23=(b(3)-A(3,1)*y1)./A(3,2);
figure
plot(y1,x21,'r',y1,x22,'k',y1,x23,'b');
hold on
Lv = x21 >= x22; % Logical Index To Selecet Vector Segments
patch([y1(Lv) flip(y1(Lv))], [x21(Lv) flip(x22(Lv))], 'g') % Use 'Lv' With 'patch' To Fill The Required Region
hold off
This approach can easily be used to fill other areas of the plot, as required. This requires one indexing line to create ‘Lv’ and one patch call.
.

カテゴリ

Help Center および File ExchangeProblem-Based Optimization Setup についてさらに検索

タグ

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by