フィルターのクリア

How to plot the area between the 2 curves with transparency 50% ?

5 ビュー (過去 30 日間)
Mustafa Sobhy
Mustafa Sobhy 2022 年 2 月 13 日
回答済み: Star Strider 2022 年 2 月 13 日
y = [0;2;4;8;12;15;19;21;23;26;29;32;36;40;43;45];
h=[-0.4270; -0.3210;-0.3600;-0.2967;-0.1400;-0.0876;-0.2430;-0.4170;-0.9860;-0.7460;-0.6430;-0.5470;-0.4300;-0.3210;-0.2500;-0.2890];
l=[-0.2200;-0.1060;-0.1150;-0.0640;0.0550;0.0870;-0.0309;-0.2110;-0.7630;-0.5440;-0.4410;-0.3650;-0.2290;-0.1160;-0.0590;-0.0946];
plot(y,h,'b');hold on;
plot(y,l,'b');

採用された回答

Star Strider
Star Strider 2022 年 2 月 13 日
y = [0;2;4;8;12;15;19;21;23;26;29;32;36;40;43;45];
h=[-0.4270; -0.3210;-0.3600;-0.2967;-0.1400;-0.0876;-0.2430;-0.4170;-0.9860;-0.7460;-0.6430;-0.5470;-0.4300;-0.3210;-0.2500;-0.2890];
l=[-0.2200;-0.1060;-0.1150;-0.0640;0.0550;0.0870;-0.0309;-0.2110;-0.7630;-0.5440;-0.4410;-0.3650;-0.2290;-0.1160;-0.0590;-0.0946];
figure
plot(y,h,'b')
hold on
plot(y,l,'b')
patch([y; flipud(y)], [h; flipud(l)], 'r', 'FaceAlpha',0.5, 'EdgeColor','none')
hold off
The approach is to create a closed, continuous curve for patch to fill. That is the reason for the flip (here flipud) calls.
See the docujmentation on patch for more information on it.
.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePolygons についてさらに検索

タグ

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by