0

I am trying to plot an uncomplete data set using the contourf function. A minimum working example of this is

figure()

hold on;

scatter([1, 2, 3, 4, 5], [1, 1, 1, 1, 1])

scatter([1, 2, 3, 4, 5], [2, 2, 2, NaN, NaN])

scatter([1, 2, 3, 4, 5], [NaN, NaN, 3, 3, 3])

contourf([1, 2, 3, 4, 5],[1, 2, 3],[[10, 12, 20, 15, 11]; [8, 17, 7, NaN, NaN]; [NaN, NaN, 21, 19, 15]]);

hold off;

This produces the following figure: Contour plot of incomplete data set

What is the reason that the contour plot does not include all available data points? The result I would have expected would look something like this: Expected contour plot

Is it possible to reach that result?

Axel
  • 1,415
  • 1
  • 16
  • 40
  • Consider the square with vertices `{(4,3), (5,3), (5,2), (4,2)}` and respective values `{19, 15, NaN, NaN}`. I wouldn't expect an interpolating function to return anything other than `NaN` throughout the interior of this. Looks like `contourf` is evaluating grid-square by grid-square. To me, what MATLAB returns is entirely expected. What value would you expect at `(4, 2.5)`? – Steve Dec 11 '17 at 10:21
  • Hm I would have thought that for Matlab it would be possible to interpolate e.g. in the triangle {(3,2), (4,3), (5,3)} by interpolating the boundary lines {(3,2), (5,3)} and {(4,3),(5,3)}. At our department some colleagues are using uniplot for similar problems and it seems to be possible. E.g look at http://www.uniplot.de/documents/de/_images/ResizeDiagram.png – Axel Dec 11 '17 at 10:31
  • @Axel you can interpolate it yourself the way you want it. Looks like creators of this particular function decided not to connect any vertices if they are further than one index apart from each other. – Artyom Emelyanenko Dec 11 '17 at 14:00

0 Answers0