Caching a large 3D interpolation using griddata()

3 次查看(过去 30 天)
I'm using griddata() to go from a spherical grid of sizes on the order (128x256x1500) to a Cartesian cube centered on the sphere, containing N^3 regularly-spaced points (where N is between 128 and 512). I need to do this for dozens or hundreds of checkpoints in my simulation, and several variables per checkpoint. I'm going to need to interpolate from the same spherical grid to the same cubic grid several hundred or several thousand times over, using new data on the spherical grid each time!
Since the most computationally expensive part of this routine is the triangulation and interpolation, I would like to cache some information the first time the routine is run and use that information for subsequent runs.
As far as I can tell, this is not possible using the current implementation of griddata(). Is there any way I could do something like this -- perhaps re-writing the griddata() routine?

回答(1 个)

Matt J
Matt J 2014-7-5
编辑:Matt J 2014-7-5
In recent versions of MATLAB, you have scatteredInterpolant which pre-composes an interpolation object, so probably does some of the caching you're talking about. Beyond that, there is parfor in the Parallel Computing Toolbox, if you have it. You would probably have to be strategic about how you slice the input and output data, if you go that route.
  2 个评论
Jess
Jess 2014-7-5
Thanks for your quick response!
The scatteredInterpolant class is not quite what I'm looking for, unfortunately. Suppose I have values (Y) defined on a set of points (X), and after interpolation I have (Y1) defined on (X1). The scatteredInterpolant class allows me to save X and Y, such that if I give it a new set of points (X1), it gives me a new set of interpolated values (Y1). It's saving information about the 3D function so that I can interpolate at several new points.
What I want do is to save information about the geometry. I want to re-use X and X1, such that I can give it a new Y and it will give me a new Y1.
Does this make sense?
Thanks again!
Matt J
Matt J 2014-7-5
编辑:Matt J 2014-7-5
It might be worthwhile having a look at FUNC2MAT. It will let you express the interpolation as a multiplication of Y(:) with a reusable sparse matrix that is (X,X1)-dependent. The computation of this matrix will be time-consuming, but if you'll be reusing it enough, it might be worth it. FUNC2MAT also lets you mitigate the matrix computation using the Parallel Computing Toolbox, if you have it.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Interpolation 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by