How can I fill in the area between two curves? The curves are not the same length and also don't form a closed shape.
Show older comments


The plot at the top is an example of what I have. There are two data series. The top series (filled squares) represents maximum values of my data. For each maximum value data point, there is usually (but not always) a minimum value data point vertically below.
I would like to do something like in the second figure, where I shade the area between the two curves--or better still, between each data pair (the maximum and minimum value at a particular x axis value) and plot one of the points in the pair as solid.
My problem is that I have been through previous questions here and can't get anything to work for my situation. In my example, there is a minimum value for each maximum value but that is not always the case and also, the two curves don't form a closed shape. The errors I'm getting seem to be related to these issues. Does anyone know if there's a straightforward way to do this? Thank you for any advice.
Here are the data. I left the "NaN" in because that's the nature of my data and I have to deal with them.
%x1 and x2
1.0000
3.0000
4.5000
6.0000
8.0000
11.0000
16.0000
20.0000
25.0000
30.0000
16.0027
24.1943
27.7769
34.8065
44.5189
56.2825
68.2554
73.0484
76.4253
NaN
%y2
14.0410
20.9402
25.0441
30.4932
36.3988
50.6604
61.9821
71.4331
73.9582
NaN
Accepted Answer
More Answers (0)
Categories
Find more on Interpolation of 2-D Selections in 3-D Grids in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
