MATLAB: Issue creating contour plot from interpolated data

contourcontourfgriddataMATLABmeshmeshgridtriscatteredinterp

I've imported data into Matlab from a thermal Finite Difference which simulates the temperature profile produced on the surface of a metal plate during electron beam welding. The imported data contains the X-Y coordinates of isotherms produced during an electron beam welding process.
Because the data set I'm importing contains the coordinates of contour curves for varying temperatures (instead of an evenly distributed temperature data set) I'm having trouble producing a contour colourmap in Matlab from the data.
Image 1 – Plot of the imported data
I tried using a couple of the interpolation functions in Matlab to produce a data grid (griddata and Triscatteredinterp) but have had limited success as shown below:
Image 2 – Contourf plot of interpolated data
Image 3 – mesh plot of interpolated data
The data that is being imported is a tab delimited text file containing 3 columns of data: X, Y and the corresponding temperature for each X-Y coordinate.
I've tried removing data points to aid the interpolation but that hasn't been too successful. Is there a better way of doing this?
Thanks in advance

Best Answer

Sigh. This data is insufficient to generate a surface, and therefore a contour plot, with any degree of accuracy.
Worse, use of a tool like a tessellation (Triscatteredinterp) is a obscenely bad way to build that surface. Your data has huge expanses between those ovals where no information is provided, but a triangulation MUST span the holes. So you end up with long, thin triangles, which are abominations when doing interpolation.
My gridfit will be a bit better than using triscatteredinterp here, but not by much. (See the example of using gridfit where I recover the surface of a hillside from a set of topographic contour lines.) Again, your data is simply too limited to do this job well. And gridfit will attempt to extrapolate the surface outside of the domain of your data, since it works on a regular lattice.
One option is to use a tool like an adaptive surface modeling tool I've written, that starts with a triangulation of the domain, then adaptively refines the triangulation, while fitting a surface to the data using a scheme similar to gridfit. I've never posted this tool on the FEX, but it does work reasonably well in my tests. If you wish to send me some data, I can test it out to see if that algorithm would work for you.