Difference between the griddata and the source data when creating contour

3 次查看(过去 30 天)
Hello,
I have some random scatter data in X, Y Z format and would like to create the contour based on them. The data are processed using the meshgrid and griddata method. After comparing the contour and the source data, the contour level line is not matching the source data.
In the figure below, you can see the source data plotted against the contour. The scource data values are actually known for each line, like the marked 30, 29, 28. I was expecting the contour level line should match the line drawn by the source data.
I tried different interpolation method and the linear method give the best results as shown below.
Any suggestions to solve this problem?
Thanks

采纳的回答

Walter Roberson
Walter Roberson 2023-10-5
griddata() is based upon first triangulating the input points (unless 'v4' method is specified). triangulation of sparse 3D surfaces can give unexpected results. It is common for long thin triangulations between distant points to end up being created.
The denser the sparse data, the more likely it is for the triangulation to "mostly" follow the known surface fairly well. But especially if the surface was sampled more closely in one dimension than another dimension, the triangulation can end up fairly odd.
If you know something about the distribution of sample points, it can at times be better if you construct your own triangulation before doing the interpolation. But a lot of the time you do not know anything about the distribution, and you just have to live with the fact that what you get out is an approximation.
  2 个评论
Ali
Ali 2023-10-5
Hello Walter,
Stephen proposed a solution but that will need reshape the data. What do you think that reshape the data can make the contour smoother?
Thanks
Walter Roberson
Walter Roberson 2023-10-5
In that particular question, @Stephen23 was replying for a situation in which the data followed a rectangular quasi-grid .
In the information you have given us so far, we do not know if that is what you have available for your samples. For example if you were more or less working with a "compressive sensing" situation, then you would not have a quasi-grid.

请先登录,再进行评论。

更多回答(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