This function returns a list of 3xM indices into x and y, where M is the number of triangles. First, extract the Delaunay Triangularisation of our points: Wouldn’t it be nice to simply resample within the original? Delaunay interpolation We could then delete the outsiders, but that would require additional processing. If we resampled this function over a regular grid using scatteredInterpolant, we’d end up with points outside the original region, which might not always be appropriate. I’ve left out the edge lines in the bottom-right graph to emphasise this. But even with interpolated shading, there’s significant distortion along certain diagonals. Note that without the interpolated shading, the plot is basically unusable. What if you just want to improve the look of your overly-coarse surface plot? Here’s the example using trisurf described above, with and without interpolated shading ( shading interp): Good old Matlab.) Surf plots with coarse scattered dataīut what about scattered data? While Matlab does provide scatteredInterpolant, this form is only really convenient if you want to interpolate onto a regular grid. (The transpose being necessary from coordinates output from peaks. Gridded interpolation can be done in a number of ways for this example I used This is quite a coarse interpolation, but couldn’t go finer without the edges taking over in the 3D plot. (Colours are smeared along diagonals, basically.)įinally, in the third row an interpolation function is used to generate more data points. It’s an improvement, but distortions are obvious where there are large changes in both directions. In the second row, Matlab’s interpolating shader is used to “improve” this. It can be seen that the colours of each “patch” don’t do a good job of representing their height (or “value”). This can be seen in the following example, using peaks to plot a surface: The problem is that surface plots are poor at visualising data over coarse meshes, since it’s their corners which define the values. Seems slightly redundant, but easy enough. Z = randn(1,N) % "value" at each coordinateĪfter a little digging, you’ll find that the easiest way to plot this data as a surface is: Matlab provides commands for analysing this data using Delaunay Triangulation, for which it also provides an analogue to surf. The structure of the surf command simply doesn’t handle data in this form, since the data isn’t organised in a way that allows adjacent points to be connected. In this case your data would be organised with x, y, and z as column vectors with each measurement per row. If you have sampled data with non-uniform spacing, however, it’s not as obvious how to plot that data. The variables x and y are 10x10 matrices defined by (the equivalent of) =meshgrid(linspace(-3,3,10)), and z is the value at each point in (x,y) space. Generally I recommend avoiding 3D plots, so in 2D ( view(2)): Plotting surfaces over grid points is easy using Matlab’s surf command, and interpolation of that data to get smoother plots is straightforward. Matlab has a number of methods for interpolating data, both for data that is sampled on a regular grid and for data that is “scattered”, or randomly distributed.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |