Issue creating contour plot from interpolated data
8 views (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
John D'Errico
on 6 Jun 2011
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.
2 Comments
More Answers (1)
Bjorn Gustavsson
on 8 Jun 2011
Since the curves are isoterms you should not be far away from a contour plot. Here I'm just assuming that you get the curves in a nice and sorted order (otherwise you'll have to do some sorting).
Temps = unique(T);
clrs = jet(length(Temps));
for i1 = 1:length(Temps),
ph(i1) = plot(X(T==Temps(i1)),Y(T==Temps(i1)));
hold on
set(ph(i1),'color',clrs(i1,:))
end
If it isn't exactly isoterms you might have to treat the temperatures with some tolerances. If you want a larger number of isoterm countours you should export them from the simulation - not invent them by interpolation.
0 Comments
See Also
Categories
Find more on Contour Plots in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!