Fill the gap between two lines
17 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Cora Boriga
il 8 Gen 2024
Commentato: Image Analyst
il 11 Gen 2024
Hello,
I'd like to fill the gap between two a curve and a line, but only when the curve is above the line.
This is my actual code:
curve = F(:,2)';
line = 13;
plot(curve,'k');
hold on;
area(x,curve,line,'FaceColor','c','LineWidth',1);
yline(line, '--r',LineWidth=2)
Thankyou for your help!

0 Commenti
Risposta accettata
Cris LaPierre
il 8 Gen 2024
I think you could accomplish this by modifying the data you pass into area so that y is lever less that line.
max(curve,line)
For example:
x = 0:0.1:10;
curve = 5*sin(x) + 10;
line = 13;
plot(x,curve,'k');
hold on;
area(x,max(curve,line),line,'FaceColor','c','LineWidth',1);
hold off
yline(line, '--r',LineWidth=2)
4 Commenti
Image Analyst
il 11 Gen 2024
If this Answer solves your original question, then could you please click the "Accept this answer" link to award the answerer with "reputation points" for their efforts in helping you? They'd appreciate it. Thanks in advance. 🙂 Note: you can only accept one answer (so pick the best one) but you can click the "Vote" icon for as many Answers as you want. Voting for an answer will also award reputation points.
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


