Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Using griddata with method 'v4'

Subject: Using griddata with method 'v4'

From: Daniel Drori

Date: 3 May, 2009 15:59:01

Message: 1 of 16

Hi there,

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
daniel@tehila.gov.il

Subject: Using griddata with method 'v4'

From: Daniel Drori

Date: 3 May, 2009 16:08:02

Message: 2 of 16

...

Subject: Using griddata with method 'v4'

From: Bruno Luong

Date: 3 May, 2009 16:21:01

Message: 3 of 16

"Daniel Drori" <daniel.drori@gmail.com> wrote in message <gtkf05$cuc$1@fred.mathworks.com>...

> 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

Subject: Using griddata with method 'v4'

From: John D'Errico

Date: 3 May, 2009 22:57:01

Message: 4 of 16

"Daniel Drori" <daniel.drori@gmail.com> wrote in message <gtkf05$cuc$1@fred.mathworks.com>...
> Hi there,
>
> 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'??

'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

Subject: Using griddata with method 'v4'

From: Daniel Drori

Date: 27 May, 2009 11:49:01

Message: 5 of 16


> > 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'??
>
> '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

Subject: Using griddata with method 'v4'

From: John D'Errico

Date: 27 May, 2009 13:46:01

Message: 6 of 16

"Daniel Drori" <daniel.drori@gmail.com> wrote in message <gvj9bd$mda$1@fred.mathworks.com>...

> 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

Subject: Using griddata with method 'v4'

From: Steven Lord

Date: 27 May, 2009 13:56:51

Message: 7 of 16


"Daniel Drori" <daniel.drori@gmail.com> wrote in message
news:gvj9bd$mda$1@fred.mathworks.com...

*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
slord@mathworks.com

Subject: Using griddata with method 'v4'

From: Bruno Luong

Date: 28 May, 2009 19:40:17

Message: 8 of 16

A question to John:

- 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

Subject: Using griddata with method 'v4'

From: Joaquim Luis

Date: 28 May, 2009 20:09:02

Message: 9 of 16


> 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

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

Subject: Using griddata with method 'v4'

From: John D'Errico

Date: 28 May, 2009 21:04:02

Message: 10 of 16

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <gvmpb1$ln1$1@fred.mathworks.com>...
> A question to John:
>
> - 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

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

Subject: Using griddata with method 'v4'

From: Bruno Luong

Date: 28 May, 2009 21:22:01

Message: 11 of 16

Thank you John. Your opinion is informative as always.

Bruno

Subject: Using griddata with method 'v4'

From: John D'Errico

Date: 28 May, 2009 21:39:02

Message: 12 of 16

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <gvmv9p$sb$1@fred.mathworks.com>...
> Thank you John. Your opinion is informative as always.
>
> Bruno

I'll send it to you if you wish to try it out.

Let me know.

John

Subject: Using griddata with method 'v4'

From: Bruno Luong

Date: 29 May, 2009 06:49:02

Message: 13 of 16

Thank you John. Right now I'm using the 'v4'. I have to finalize the code soon for delivery, no time to play with other methods. I'll be happy to contact you later to test the scattered interpolation code.

Cheers,

Bruno

Subject: Using griddata with method 'v4'

From: Neema

Date: 2 Jan, 2012 00:32:08

Message: 14 of 16

"John D'Errico" <woodchips@rochester.rr.com> wrote in message <gvmu82$kin$1@fred.mathworks.com>...
> "Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <gvmpb1$ln1$1@fred.mathworks.com>...
> > A question to John:
> >
> > - 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
>
> 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

John,

It would be very useful if you can post that version of gridfit that works on triangulated domains. Now it is quite a while from this message but you still didn't include it in the file exchange distribution.

Thanks in advance

Subject: Using griddata with method 'v4'

From: Peter Mao

Date: 8 May, 2013 18:28:09

Message: 15 of 16

"John D'Errico" <woodchips@rochester.rr.com> wrote in message <gvjg6p$fbb$1@fred.mathworks.com>...
...
> 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.)

Hi John,

my experience with 'v4' (based on Sandwell, 1987) doesn't exactly conform to what you're saying here. Indeed, it is slow, but I found that it handled "intrapolation" better than the other interpolation methods available in Matlab (I checked out 'nearest', 'linear' and 'cubic (spline)').

I can post up specifics, if you're interested in discussing this further.

Also, to expand on the topic of interpolation methods in 2D, do you have any insight on Shepard's method (Shepard, ACM, 1968) or the triangular interpolation method of Cline and Renka (1984)? Those are scattered-data 2D interpolation methods in NAG that I haven't seen in Matlab (maybe in the File Exchange?).

Peter

Subject: Using griddata with method 'v4'

From: John D'Errico

Date: 8 May, 2013 20:17:16

Message: 16 of 16

"Peter Mao" wrote in message <kme5fp$fgb$1@newscl01ah.mathworks.com>...
> "John D'Errico" <woodchips@rochester.rr.com> wrote in message <gvjg6p$fbb$1@fred.mathworks.com>...
> ...
> > 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.)
>
> Hi John,
>
> my experience with 'v4' (based on Sandwell, 1987) doesn't exactly conform to what you're saying here. Indeed, it is slow, but I found that it handled "intrapolation" better than the other interpolation methods available in Matlab (I checked out 'nearest', 'linear' and 'cubic (spline)').
>
> I can post up specifics, if you're interested in discussing this further.
>
> Also, to expand on the topic of interpolation methods in 2D, do you have any insight on Shepard's method (Shepard, ACM, 1968) or the triangular interpolation method of Cline and Renka (1984)? Those are scattered-data 2D interpolation methods in NAG that I haven't seen in Matlab (maybe in the File Exchange?).
>
> Peter

Peter, I won't argue with you. Feel free to use it or not.

My comments stand. Period. Beyond that, I am retired
and will not re-enter a conversation from years ago.

John

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us