No BSD License  

Highlights from
tinterp - an alternative to griddata

5.0

5.0 | 3 ratings Rate this file 29 Downloads (last 30 days) File Size: 3.58 KB File ID: #13183
image thumbnail

tinterp - an alternative to griddata

by

 

30 Nov 2006 (Updated )

Linear and quadratic interpolation for scattered data

| Watch this File

File Information
Description

Provides linear and quadratic interpolation methods for functions defined on scattered 2D datasets.

The quadratic method in tinterp seems to be superior when compared to the cubic method in gridata.

Type "help tinterp" & "help tester"

MATLAB release MATLAB 6.5 (R13)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (5)
09 May 2012 Jo Williams

Three years later and I'm still using it, but this code falls over in Matlab 2012a because TSEARCH has been removed. The following substitution fixes it:

%i = tsearch(p(:,1),p(:,2),t,pi(:,1),pi(:,2));

becomes
i = tsearchn(p,t,pi);

DelaunayTri and pointLocation are suggested by the error message, and may provide a speed improvement, but since I've saved a load of triangles the old way I don't really want a major rewrite!

Jo

07 Sep 2009 carlos lopez

I would like to have more information of the theory behind this. What it means that it is "quadratic"? Should it be exact for 2nd. degree functions? I tried this
X=[1:10 1:10];Y=[zeros(1,10) ones(1,10)];%Data points
f=100*(X').^2; %data points
tri=delaunay(X,Y);%Triangulation
triplot(tri,X,Y) %to interpret the case
x=linspace(0,11,300);y=repmat(0.5,1,300);
fC=tinterp([X' Y'],tri,f,x,y,'quadratic');
plot(diff(fC));%should be linear if the interpolant is exact for 2nd degree

Apparently from this example the interpolant is C0 (i.e. continuous but not differentiable), but it is a little bit misleading what is meant by "quadratic".

I tried to contact the author before posting, but apparently changed addres. Thank you anyway for his contribution.

14 May 2009 Jo Williams  
07 Feb 2008 Craig M.

I make hundreds of 2D interpolations for a given triangulation. This function is exactly what I need. Thx.

01 Dec 2006 John D'Errico

An alternative to griddata - similar in speed when you add in the time for the triangulation.

The advantage of this code is if you already have a triangulation, then this saves the time to regenerate it. It also allows you to use a custom, non-delaunay triangulation - not an option at all for griddata.

A disadvantage of this code is it forces you to do the triangulation to call it. Its an unnecessary step for many people, so I'd probably be tempted to allow the user to not supply the triangulation, so if t is empty it could just call delaunay.

This code offers properties similar to griddata. It will not extrapolate beyond the convex hull of the data, Extrapolation is risky business of course, so thats not necessarily bad.

Good help, examples. The quadratic interpolant is an interesting idea.

Contact us