How to fill space between two lines?

7 次查看(过去 30 天)
Hi, I have this code:
H_up = [0,cosd(80)*7.387/10,cosd(70)*7.985/10,cosd(60)*8.906/10,cosd(50)*1.025,cosd(40)*1.238,cosd(30)*1.155,cosd(20)*1.064,cosd(10)*1.015,1];
H_lo = [0,cosd(80)*7.243/10,cosd(70)*7.826/10,cosd(60)*8.734/10,cosd(50)*1.009,cosd(40)*1.218,cosd(30)*1.137,cosd(20)*1.062,cosd(10)*1.015,1];
M_up = [7.021/10,sind(80)*7.387/10,sind(70)*7.985/10,sind(60)*8.906/10,sind(50)*1.025,sind(40)*1.238,sind(30)*1.155,sind(20)*1.064,sind(10)*1.015,0];
M_lo = [6.897/10,sind(80)*7.243/10,sind(70)*7.826/10,sind(60)*8.734/10,sind(50)*1.009,sind(40)*1.218,sind(30)*1.137,sind(20)*1.062,sind(10)*1.015,0];
plot(H_up,M_up)
hold on
plot(H_lo,M_lo)
I would like to fill space between those lines with some color, say light-blue. How to do that?
Thanks,
Lukasz

采纳的回答

Star Strider
Star Strider 2019-1-17
Try this:
H_up = [0,cosd(80)*7.387/10,cosd(70)*7.985/10,cosd(60)*8.906/10,cosd(50)*1.025,cosd(40)*1.238,cosd(30)*1.155,cosd(20)*1.064,cosd(10)*1.015,1];
H_lo = [0,cosd(80)*7.243/10,cosd(70)*7.826/10,cosd(60)*8.734/10,cosd(50)*1.009,cosd(40)*1.218,cosd(30)*1.137,cosd(20)*1.062,cosd(10)*1.015,1];
M_up = [7.021/10,sind(80)*7.387/10,sind(70)*7.985/10,sind(60)*8.906/10,sind(50)*1.025,sind(40)*1.238,sind(30)*1.155,sind(20)*1.064,sind(10)*1.015,0];
M_lo = [6.897/10,sind(80)*7.243/10,sind(70)*7.826/10,sind(60)*8.734/10,sind(50)*1.009,sind(40)*1.218,sind(30)*1.137,sind(20)*1.062,sind(10)*1.015,0];
plot(H_up,M_up)
hold on
plot(H_lo,M_lo)
patch([H_up fliplr(H_lo)], [M_up fliplr(M_lo)], [0.6 0.8 1.0])
hold off
See the documentation on the patch (link) function to understand how it works.

更多回答(0 个)

类别

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

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by