How to shade area between an upper bound and lower bound curve?

조회 수: 12 (최근 30일)
Andrew Poissant
Andrew Poissant 2018년 1월 18일
댓글: Star Strider 2018년 1월 18일
I have an upper bound curve comprised of vectors xmax, ymax. I also have a lower bound curve comprised of vectors xmin, ymin. The two curves do not connect to make a polygon but have the same number of elements. All four vectors are 1x361. How could I shade the area in between the curves given the upper and lower bounds? The .mat files for each vector are attached.

채택된 답변

Star Strider
Star Strider 2018년 1월 18일
It would help to have at least a sample of your data. Without it, a guess is the best I can do.
With the monotonically-increasing x-vector in the first row, and the y-vector in the second row for each matrix, use the patch (link) function:
v = rand(1, 361);
vs = sort(v);
UpperBound = [vs; v + 3];
LowerBound = [vs; v + 1];
figure(1)
patch([UpperBound(1,:) fliplr(LowerBound(1,:))], [UpperBound(2,:) fliplr(LowerBound(2,:))], [0.1 0.5 0.9], 'EdgeColor','none')
Note: The patch function will close the curve on its own.
  댓글 수: 4
Andrew Poissant
Andrew Poissant 2018년 1월 18일
This is perfect, thank you for the help!
Star Strider
Star Strider 2018년 1월 18일
As always, my pleasure!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Contour Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by