Effacer les filtres
Effacer les filtres

How to fill space between two lines?

7 vues (au cours des 30 derniers jours)
Lukasz Skowron
Lukasz Skowron le 17 Jan 2019
Commenté : Star Strider le 17 Jan 2019
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

Réponse acceptée

Star Strider
Star Strider le 17 Jan 2019
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.
  2 commentaires
Lukasz Skowron
Lukasz Skowron le 17 Jan 2019
Thanks, it does exactly what I wanted!
Star Strider
Star Strider le 17 Jan 2019
As always, my pleasure!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Produits


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by