Simulating scatteredInterpolant for improved performance.

5 ビュー (過去 30 日間)
Alexander Shtof
Alexander Shtof 2017 年 8 月 2 日
コメント済み: Alexander Shtof 2017 年 8 月 4 日
I have a set of 3D points X and a set of query points Q. I would like to interpolate function values at the query points Q, given various function values on X. Currently, my code looks something like this:
F = scatteredInterpolant(X, v1);
r1 = F(Q);
F.Values = v2;
r2 = F(Q);
F.Values = v3;
r3 = F(Q);
...
My code works slowly. However, I noticed that I can use the fact that the query points are always the same. I would like to simulate scatteredInterpolant by constructing delaunay triangulation of X, computing the barycentric weights of Q, and use the above results to interpolate the function values. However, I do not understand exactly what happens if some of the points of Q fall outside the convex hull of F. How does scatteredInterpolant (with linear extrapolation) behave in this case?

回答 (1 件)

Matt J
Matt J 2017 年 8 月 2 日
編集済み: Matt J 2017 年 8 月 2 日
One approach which would avoid the need to understand the internals of scatteredInterpolant would be to use my FUNC2MAT ( Download ) submission. Since the desired operation is a linear function of v, you can express it as a Q-dependent matrix, M.
function r=func(v,F,Q)
F.Values=v;
r=F(Q);
end
F = scatteredInterpolant(X, v1);
M=func2mat(@(v) func(v,F,Q) , v1);
r1=M*v1(:);
r2=M*v2(:);
etc...
I suspect it could be a slow process for func2mat to compute M. Whether this is worthwhile depends on how many times M would be used.
  3 件のコメント
Matt J
Matt J 2017 年 8 月 3 日
編集済み: Matt J 2017 年 8 月 3 日
Bear in mind that the M matrix is intended to be computed only once, not each time you call the function. You're meant to reuse M if possible for any subsequent computation of r_i depending on the same query points, Q
Alexander Shtof
Alexander Shtof 2017 年 8 月 4 日
I know. But the M matrix is also re-computed a lot. The code fragment I showed is called many times, and each time it is called it needs to re-compute M and use it several times to interpolate several function values.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDelaunay Triangulation についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by