How can I make MATLAB shade the area of the virtual intersection between two lines?
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Ali Almakhmari
le 11 Sep 2021
Réponse apportée : Star Strider
le 12 Sep 2021
The below code will plot a figure of two lines (red and blue) and few dashed lines to help you visualize what I am talking about. Is there a way I can make MATLAB shade the region that is occupied by both lines? If you don't know what I mean, its the rectangular region bounded by the dashed lines made from the two lines.
x1 = ones(1,10);
y1 = ones(1,1000000);
n1 = 10^10:10000000000:10^16;
T1 = 10:1:19;
loglog(n1, y1, 'LineWidth', 2)
hold on
loglog(x1, T1, 'LineWidth', 2)
%%Shaded Lines code
d = 1:10^15:10^16;
e = 1:1:100;
d1 = [10, 10, 10, 10, 10, 10, 10 , 10, 10, 10, 10];
d2 = [19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19];
d3 = zeros(1,100)+10^10;
d4 = zeros(1,100)+10^16;
loglog(d, d1, 'k--')
loglog(d, d2, 'k--')
loglog(d3, e, 'k--')
loglog(d4, e, 'k--')
0 commentaires
Réponse acceptée
Star Strider
le 12 Sep 2021
Both fill and patch require a closed region —
x1 = ones(1,10);
y1 = ones(1,1000000);
n1 = 10^10:10000000000:10^16;
T1 = 10:1:19;
figure
loglog(n1, y1, 'LineWidth', 2)
hold on
loglog(x1, T1, 'LineWidth', 2)
%%Shaded Lines code
d = 1:10^15:10^16;
e = 1:1:100;
d1 = [10, 10, 10, 10, 10, 10, 10 , 10, 10, 10, 10];
d2 = [19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19];
d3 = zeros(1,100)+10^10;
d4 = zeros(1,100)+10^16;
loglog(d, d1, 'k--')
loglog(d, d2, 'k--')
loglog(d3, e, 'k--')
loglog(d4, e, 'k--')
patch([d3(1) d4(1) d4(1) d3(1)], [d1(1) d1(1) d2(1) d2(1)], 'g', 'FaceAlpha',0.5)
This instance is relatively straightforward.
.
0 commentaires
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur Surface and Mesh Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!