I'm working on a project and I need to build a 3d surface by giving the coordinates: x,y,z. I use the following code:
PictureSize = size(A);
ty = 1:1:PictureSize (1);
tx = 1:1:PictureSize (2);
[X,Y] = meshgrid(tx,ty);
Z = griddata(x,y,z, X, Y,'v4');
surf(X,Y,Z);
I tried to use the method 'cubic' instead of 'v4' but it gives me a lot of NaN's, and when I start using the method 'v4' I start getting real values.
I have several questions:
1) What are the differences between the two methods 'cubic' and 'v4'??
2) Where can I read about the method 'v4' in order to know how it works?
3) Is there any way I can translate the 'griddata' function with the method 'v4' to C++?
Please help me...
Thanx in advance
Daniel Drori
dan...@tehila.gov.il
> 2) Where can I read about the method 'v4' in order to know how it works?
According to the doc, v3 method is derived here:
[2] Sandwell, David T., "Biharmonic Spline Interpolation of GEOS-3 and SEASAT Altimeter Data", Geophysical Research Letters, 14, 2, 139–142,1987.
"Seasat" altimeter data is the sea surface height (SSH) data acquired by the a satellite called SEASAT; -)
Bruno
'cubic' is a triangulation based method. So if a point
is outside the convex hull of the data, then you won't
find a triangle that contains it. Therefore ... NaN.
'v4' is apparently a Greens' function approach. It uses
a full matrix composed of ALL of the interpoint
distances. This will be SLOW for many points, and
extremely memory intensive.
> 2) Where can I read about the method 'v4' in order to know how it works?
> 3) Is there any way I can translate the 'griddata' function with the method 'v4' to C++?
>
Just pick any radial basis function method. There
are many of them to be found. In fact, there are
RBF codes on the file exchange.
These RBF methods are not always terribly good.
I originally played with them for a year or so,
before developing the ideas behind gridfit, which
works FAR better on the problems I've ever seen,
as well as giving you more control over the results.
John
hi John,
concerning my questions:
1) What are the differences between the two methods 'cubic' and 'v4'??
2) Where can I read about the method 'v4' in order to know how it works?
are there any researches so I can read them?
why do I get negative values when I use V4?
is there any way to get Nan's with v4? why?
basically, all I need to know is how dose this method calculate the 3d surface i get..
thanx in advance
Daniel
> hi John,
> concerning my questions:
> 1) What are the differences between the two methods 'cubic' and 'v4'??
Think of the 'cubic' method as a version of a spline,
on a triangular support. So you will have cubic
pieces in 2 dimensions. I'd expect to see derivative
breaks of some order across the triangle boundaries.
The 'v4' method is much like a radial basis function
interpolant. These methods are distance based
methods, so you will have a single radially symmetric
basis function around EVERY data point. The 'v4'
method will form a linear combination of these basis
functions, so it must formulate and solve a linear
system of equations, of size the number of data
points.
> 2) Where can I read about the method 'v4' in order to know how it works?
> are there any researches so I can read them?
There are many such interpolants, multi-quadric and
inverse multi-quadric. Read Richard Franke's paper
on this subject (Mathematics of Computation) for
a good discussion of
R. Franke, "Scattered Data Interpolation: Tests of Some
Methods", Mathematics of Computation, 1982
> why do I get negative values when I use V4?
It has no constraint on the value it predicts, merely
interpolating your data. However, locations between
the data points and exterior to them may take on
any value that is consistent with the interpolant used.
Any polynomial interpolant has similar behaviors.
The 'v4' method is a poor choice in general, IMHO.
It is slow. It will do nasty things to you in extrapolation,
as well as in "intrapolation". (Intrapolation is a word
of mine that describes interpolation across a large
internal hole in your data. This can have many of the
bad characteristics of extrapolation.)
> is there any way to get Nan's with v4? why?
Not unless you have NaNs in the data iself, or possibly,
replicate data points. As described above, 'v4' is a
distance based method that solves a linear system of
equations for the solution. NaNs will occur only if
there are already NaNs in the data, or if there are
replicate points in your set. The latter case will
generate a singular system, so might introduce NaNs
in the solution.
The other methods of griddata introduce NaNs because
they are triangulation based. Points outside of the convex
hull will cause failure here, so NaNs are returned.
John
*snip*
> 2) Where can I read about the method 'v4' in order to know how it works?
Take a look at the Algorithm and References sections of the function
reference page:
http://www.mathworks.com/access/helpdesk/help/techdoc/ref/griddata.html
It gives the journal article that describes the 'v4' method. I'm guessing
your local library may have this journal or may be able to get a copy of
that article for you.
--
Steve Lord
sl...@mathworks.com
- I have a program where I use griddata v4 from scatter to scatter with extrapolation.The interpolation/extrapolation is used for visualization purpose. I would like to try GRIDFIT. But this function seems to require a gridded target nodes. What is the reason for that? Can I trick it by calling gridfit many times as there are scattered target points and still get a coherence surface?
Bruno
Mirone has MEX files for both the GMT's "surface" program and the MB-SYSTEM equivalent (surface_m.c & gmtmbgrid_m.c). The both use the minimum curvature algorithm that is very fast and since they are MEXs user is not obliged to provide an entire full matrix for X, and Y which a find a absurd and highly limits (due to memory issues) the size of the grid one may compute. The gmtmbgrid_m computes NaNs on cells not constrained by data (controlled by an input option -C).
J. Luis
Hi Bruno,
Gridfit builds a plaid grid for a few reasons. This makes it
efficient for relatively large grids, since I can build a simple
style of regularizer easily. It is also trivial to build the
predictor array. Finally, it makes for a relatively simple
interface that can be used simply out of the box.
I have written a gridfit style code that does not require
a plaid grid. It works on a triangulated domain, and even
does so in n-dimensions. It is a little slower to build the
matrices though than gridfit, but since it will generally
work on smaller problems, the two should cancel out.
I've not really spent any serious time in optimizing it.
One thing I did do was to write a tool based on it that
does adaptive mesh refinement. So I can start with a
coarse triangulation of a domain, refining the regions
of the domain where there is significant lack of fit.
So this is the tool I'd recommend you play with here,
not gridfit.
John
Bruno
I'll send it to you if you wish to try it out.
Let me know.
John
Cheers,
Bruno