Shading an area between two intervals on a plot

Hi everyone.
I have a vector of length 100 which I have plotted to yield a graph. I would like to shade the area under the graph segmented by the two lines using the area function.
I have tried the following code and it is unfortunate that it sheds the whole area. Any help will be appreciated.
iz=linspace(15,20,6); % iz is the interval between the two xlines
yz=(FF(:,15:20)); % FF is the vector that generates the plot
area(iz,yz) % this should give me the area between two, shaded
Any corrections or better pointers are welcome.

댓글 수: 2

Lui
Lui 2020년 8월 9일
Appreciated!
As always, my pleasure!

댓글을 달려면 로그인하십시오.

 채택된 답변

Star Strider
Star Strider 2020년 8월 9일

0 개 추천

It is likely not possible to use area for this, since that is not how it was designed to be used.
It is possible to use patch, however.
Try this:
x = linspace(0, 100);
y = x.*exp(-0.07*x);
figure
plot(x, y)
q2 = ylim;
hold on
L = (x>15) & (x<20);
patch([x(L) fliplr(x(L))], [y(L), ones(1,nnz(L))*min(ylim)],'r')
hold off
grid
.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품

릴리스

R2019a

질문:

Lui
2020년 8월 8일

댓글:

2020년 8월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by