Thread Subject: griddata fails to accurately interpolate non-uniform data points

Subject: griddata fails to accurately interpolate non-uniform data points

From: Edward

Date: 16 May, 2009 18:42:01

Message: 1 of 8

I have some observations describing a surface that are non-uniformly spaced, with all three axes bound between 0 and 1. When I use griddata to interpolate the points, I get Z values well outside 0 and 1, regardless of the interpolation algorithm I use. Is there a way to plot 3D data directly from non-uniform data?

earl

Subject: griddata fails to accurately interpolate non-uniform data points

From: John D'Errico

Date: 17 May, 2009 00:28:01

Message: 2 of 8

"Edward " <eee@nmt.edu> wrote in message <gun1dp$1vo$1@fred.mathworks.com>...
> I have some observations describing a surface that are non-uniformly spaced, with all three axes bound between 0 and 1. When I use griddata to interpolate the points, I get Z values well outside 0 and 1, regardless of the interpolation algorithm I use. Is there a way to plot 3D data directly from non-uniform data?
>
> earl

I'd be surprised if that is true.

IF you are using the V4 or cubic method, but a linear
interpolant from griddata will not do what you have said.
So it is unlikely that this happens when you use ANY of
the methods in griddata.

How are you calling griddata? What is your data? Where
does it arise?

John

Subject: griddata fails to accurately interpolate non-uniform data points

From: Edward

Date: 17 May, 2009 01:33:01

Message: 3 of 8

"John D'Errico" <woodchips@rochester.rr.com> wrote in message <gunlmh$sr6$1@fred.mathworks.com>...
> "Edward " <eee@nmt.edu> wrote in message <gun1dp$1vo$1@fred.mathworks.com>...
> > I have some observations describing a surface that are non-uniformly spaced, with all three axes bound between 0 and 1. When I use griddata to interpolate the points, I get Z values well outside 0 and 1, regardless of the interpolation algorithm I use. Is there a way to plot 3D data directly from non-uniform data?
> >
> > earl
>
> I'd be surprised if that is true.
>
> IF you are using the V4 or cubic method, but a linear
> interpolant from griddata will not do what you have said.
> So it is unlikely that this happens when you use ANY of
> the methods in griddata.
>
> How are you calling griddata? What is your data? Where
> does it arise?
>
> John

I have 3, 14x50 data matrices, each matrix contains data for one axis (x,y,z). (Hence A(1,1), B(1,1),C(1,1) specifies the coordinates for one point on the surface.) Rather than present my code (obviously wrong, since it doesn't work), how do I go about plotting this surface?

Earl

Subject: griddata fails to accurately interpolate non-uniform data points

From: Bruno Luong

Date: 17 May, 2009 05:44:01

Message: 4 of 8

"Edward " <eee@nmt.edu> wrote in message <gunpgd$qab$1@fred.mathworks.com>...

>
> I have 3, 14x50 data matrices, each matrix contains data for one axis (x,y,z). (Hence A(1,1), B(1,1),C(1,1) specifies the coordinates for one point on the surface.) Rather than present my code (obviously wrong, since it doesn't work)

If you wasn't so sure about your code, I would suggest to use a weaker subject line the next time. Beside that, if you use the interpolation method different than 'linear' or 'nearest'; such as 'v4' or 'cubic', there is no warranty that the interpolated values must be within min and max of your data. Example in 1D (same non-monotonic behavior happens in 2D)

plot(spline([0 3 4], [0 0 1], linspace(0,4))

Notice the interpolated values go to negative, despite of the data [0 0 1] are all positive.

> how do I go about plotting this surface?

Use Delaunay, trisurf, meshsurf. They represents the same linear interpolant surface, as with griddata(... 'linear')

Bruno

Subject: griddata fails to accurately interpolate non-uniform data points

From: Greg Heath

Date: 17 May, 2009 08:41:17

Message: 5 of 8

On May 16, 9:33 pm, "Edward " <e...@nmt.edu> wrote:
> "John D'Errico" <woodch...@rochester.rr.com> wrote in message <gunlmh$sr.=
..@fred.mathworks.com>...
> > "Edward " <e...@nmt.edu> wrote in message <gun1dp$1v...@fred.mathworks.=
com>...
> > > I have some observations describing a surface that are non-uniformly =
spaced, with all three axes bound between 0 and 1.  When I use griddata t=
o interpolate the points, I get Z values well outside 0 and 1, regardless o=
f the interpolation algorithm I use.  Is there a way to plot 3D data dire=
ctly from non-uniform data?
>
> > > earl
>
> > I'd be surprised if that is true.
>
> > IF you are using the V4 or cubic method, but a linear
> > interpolant from griddata will not do what you have said.
> > So it is unlikely that this happens when you use ANY of
> > the methods in griddata.
>
> > How are you calling griddata? What is your data? Where
> > does it arise?
>
> > John
....

>Rather than present my code (obviously wrong, since it doesn't >work), ...

That is the most idiotic statement I've read all week.

Is hiding your mistakes more important than aiding someone who
volunteers to help you for free?

Greg

Subject: griddata fails to accurately interpolate non-uniform data points

From: Edward

Date: 17 May, 2009 18:55:03

Message: 6 of 8

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <guo871$ff5$1@fred.mathworks.com>...
> "Edward " <eee@nmt.edu> wrote in message <gunpgd$qab$1@fred.mathworks.com>...
>
> >
> > I have 3, 14x50 data matrices, each matrix contains data for one axis (x,y,z). (Hence A(1,1), B(1,1),C(1,1) specifies the coordinates for one point on the surface.) Rather than present my code (obviously wrong, since it doesn't work)
>
> If you wasn't so sure about your code, I would suggest to use a weaker subject line the next time. Beside that, if you use the interpolation method different than 'linear' or 'nearest'; such as 'v4' or 'cubic', there is no warranty that the interpolated values must be within min and max of your data. Example in 1D (same non-monotonic behavior happens in 2D)
>
> plot(spline([0 3 4], [0 0 1], linspace(0,4))
>
> Notice the interpolated values go to negative, despite of the data [0 0 1] are all positive.
>

Thanks, Bruno. TÞlaunay(x,y) looks like it will work. I'm having a problem with the output, however. x, y and z are all 1x700 vectors. Alas, T is 708x3! So when I run trisurf(T,z), T and z don't match up. I must say I find this behavior confusing...
> > how do I go about plotting this surface?
>
> Use Delaunay, trisurf, meshsurf. They represents the same linear interpolant surface, as with griddata(... 'linear')
>
> Bruno

Subject: griddata fails to accurately interpolate non-uniform data points

From: Doug Schwarz

Date: 17 May, 2009 20:41:17

Message: 7 of 8

In article <gupmi7$2rp$1@fred.mathworks.com>, "Edward " <eee@nmt.edu>
wrote:

> Thanks, Bruno. TÞlaunay(x,y) looks like it will work. I'm having a
> problem with the output, however. x, y and z are all 1x700 vectors. Alas,
> T is 708x3! So when I run trisurf(T,z), T and z don't match up. I must say
> I find this behavior confusing...

Use

  T = delaunay(x,y);
  trisurf(T,x,y,z)

T is a matrix of indices into your set of vertices, (x,y,z) so the
number of rows in T is the number of triangles. Not having the same
number of triangles as vertices is the usual case.

--
Doug Schwarz
dmschwarz&ieee,org
Make obvious changes to get real email address.

Subject: griddata fails to accurately interpolate non-uniform data points

From: Luigi Giaccari

Date: 19 May, 2009 15:17:01

Message: 8 of 8

"Edward " <eee@nmt.edu> wrote in message <gun1dp$1vo$1@fred.mathworks.com>...
> I have some observations describing a surface that are non-uniformly spaced, with all three axes bound between 0 and 1. When I use griddata to interpolate the points, I get Z values well outside 0 and 1, regardless of the interpolation algorithm I use. Is there a way to plot 3D data directly from non-uniform data?
>
> earl


I don't know your dataset, but you said x and y are the same size, maybe your points are structured, there is no need to call delaunay to traingulate them you can just use
a structured mesh generation like:

http://www.mathworks.com/matlabcentral/fileexchange/23916

Then you triangulate x and y using the tool (avoiding the slow dealaunay) and use trisurf with x,y,z

This can be hugely faster !!!!

If you want send me your models at :

giaccariluigi@msn.com

I'll give a look

Visit:
http://giaccariluigi.altervista.org/blog/

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
3d surfaces Edward 16 May, 2009 14:44:02
griddata Edward 16 May, 2009 14:44:02
plotting nonuni... Edward 16 May, 2009 14:44:02
rssFeed for this Thread

Contact us at files@mathworks.com