From: Andrew Scribner on
I am looking to interpolate a 2d set of data (well, I have X and Y coordinates that have corresponding values V). I have several parameters that depend on the same X and Y, (ie V1 through V4). Problem is, I have several different (X,Y) spaces that may be used (my data depends on a few different (X,Y) calibrations, and I specify which calibration I need by other variables T and S), so as it is I will need to call several different TriScatteredInterp's.

I can reuse some of the DelaunayTri objects that I pass to TriScatteredInterp to save processing power, so I want to call it with TriScatteredInterp(Array of DelaunayTri's, Array of vectors of V) but TriScatteredInterp does not accept vectorized input. I'd like to avoid having to loop through each datapoint (generally 6000+, so I imagine 6000 calls to TriScatteredInterp would be quite slow) but I'm unsure how to go about this and still account for the fact that different datapoints may require a different DelaunayTri input. Ive thought that maybe I can loop through my possible DelaunayTri objects (I have them indexed) and use a logical pass to the TriScatteredInterp, but that still means I need to loop through all my possible DelaunayTri's.

Any suggestions on the most efficient way to approach this? Sorry for the convoluted description, I'm having a real hard time fully describing the problem. Thanks for the help,

Andrew
From: Rune Allnor on
On 15 Des, 23:56, "Andrew Scribner" <iwantga...(a)hotmail.com> wrote:
> I am looking to interpolate a 2d set of data (well, I have X and Y coordinates that have corresponding values V). I have several parameters that depend on the same X and Y, (ie V1 through V4). Problem is, I have several different (X,Y) spaces that may be used (my data depends on a few different (X,Y) calibrations, and I specify which calibration I need by other variables T and S), so as it is I will need to call several different TriScatteredInterp's.

It depends on the variability of the coordinates, and
what kind of errors you can live with. If the (x,y)
coordinates vary only a little around fixed positions,
e.g. with variance 0.1 times the nominal step length,
you could probably get away with one triangulation.

If the variation in coordinates is large, you will
have to compute one triangulation per data set.

The only efficiency you could hope for is a parallelized
triangulation engine.

Rune
From: Andrew Scribner on
I have a feeling there must be something more than I can do, maybe I was too unclear in the description...

Say I had two XY surfaces given by:
1 1 1.5 1.5
2 1 2.5 1.5
3 1 3.5 1.5
1 3 1.5 4.5
2 3 2.5 4.5
3 3 3.5 4.5

where each surface has corresponding values V respectively given by:
10 100
20 200
30 300
40 400
50 500
60 600

I have a data set of D=xy points that needs interpolating on the top surfaces. given by:
1.75 2
2.75 2
2.25 1.75
2 2
2.5 2.5

where, finally, I have a vector, say S, that indicates which of the XY surfaces corresponds to each data point:
1
2
2
1
1

ie, data points 1, 4, and 5 of the xy data should use XY surface 1, and points 2 and 3 should use surface 2.


OK. I figure I could approach if by brute force, ie loop through the entire 5 data points with something like (just ghost coding here)
for i=1:length(datapointvector)
check S to see which surface should be used for data point i
interpolate using S for i
end
but that would be very slow, since my actual data set is 6000+ points. My second thought was maybe I could loop through all my calibration surfaces and use conditional statements to pass the necessary points, ie:
for i:numberofsurfaces %(in this case 2)
call interpolation function with input (surface_i, D(S==i))
end
that way I only call the interpolation 2 times and pass multiple data points at a time.

Those are the only ways I can think of and I think the second way should be reasonably streamlined, but I am wondering if there are any other changes I could make. Thanks again for everyone's help,

Andrew
From: Bruno Luong on
"Andrew Scribner" <iwantgames(a)hotmail.com> wrote in message <hg9c1d$d19$1(a)fred.mathworks.com>...
>I think the second way should be reasonably streamlined,

I doubt there is a better way (in Matlab) than your second way.

Your data seem to be arranged in a grid points, you can interpolate using INTERP2, no need using Delaunay and it should be relatively fast.

It is true that is (XY-grids) are common, smart algorithm could perhaps save some time by doing once the interpolation precalculation step such as grid search and building weighting coefficients (anything related to building the interpolation matrix in fact, because interpolation can be seen as a linear operator on the values). I don't believe currently Matlab allows to carry out this step alone (I could wrong though but I'm happy if someone can find a hack for it). Unless of course if you build your own interpolation routine.

Bruno