Questionable 2d interpolation results (TriScatteredInterp, griddata)
4 views (last 30 days)
Show older comments
Hi guys,
I want to interpolate 2d scattered data from a CFD simulation to a regular grid using matlab's TriScatteredInterp. I have three vectors: x,y (point coordinates) and v (fluid values).
Mesh generation and Interpolation:
xlin = linspace(min(x), max(x), 550) ;
ylin = linspace(min(y), max(y), 550) ;
[X,Y]= meshgrid(xlin, ylin) ;
Tri = TriScatteredInterp(x, y, v, 'linear') ;
Lin = Tri(X,Y) ;
The result of the interpolation seems questionable as I want to show you with some plots. The first plot shows the original scattered datapoints as well as a contour plot of the interpolation.
hold on ;
scatter(x, y, 30, v, 'filled') ;
[C,h] = contour(X, Y, Lin, '-', 'LineWidth', 1.5) ;
clabel(C,h) ;
I noticed that the contour lines in the upper part seem wavelike, in the lower part punctual. The second plot also shows my interpolation grid:
pcolor(X,Y,Lin) ;
What I expected were some mostly horizontal contour lines without those waves and punctual areas, like a smooth transition from top to bottom. I used the tool "Tecplot 360" to interpolate the exact same situation and here is what I got:
I think this is what I should get with matlab's TriScatteredInterp, too. I already tried griddata instead of TriScatteredInterp but I got the same strange results.
Is there anything I'm doing wrong with matlab's scattered data interpolation? Am I overlooking something crucial? Is there an explanation for those results?
Regards, Joe
0 Comments
Answers (3)
Matt J
on 7 Oct 2012
Edited: Matt J
on 7 Oct 2012
I don't think the problem lies in TriScatteredInterp, because the results of the Pcolor Plot agree with the results of the scatter/contour plots.
My guess is that the code that generated v is working in a different coordinate system than the meshgrid coordinate system that you've defined for TriScatteredInterp. We probably need to see more code.
9 Comments
Sean de Wolski
on 8 Oct 2012
Edited: Sean de Wolski
on 8 Oct 2012
I would first recommend what Matt was suggesting about rotating your coordinate system to be the grid. This would not require the delaunay triangulation, which is apparently not suitable for the interpolation.
Alternatively, look at John's gridfit(). He says right the description a good reason it may work for you:
Griddata is a valuable tool for interpolation of scattered data. However it fails when there are replicates or when the data has many collinear points.
2 Comments
Jette
on 22 Jan 2013
Have you tried the smoothness parameter with different values in the two dimensions? I've just had a similar result from gridfit and this solution fixed the problem for me.
Matt J
on 9 Oct 2012
It might be time to use a curve fitting tool, e.g., lsqcurvefit. It seems that you have a priori physical info, from fluid mechanics, about how this surface should behave, so a curve fitting tool would be the best vehicle for incorporating that.
0 Comments
See Also
Categories
Find more on Surface and Mesh Plots 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!