Combine griddedInterpolants on the same grid

3 ビュー (過去 30 日間)
Konrad Warner
Konrad Warner 2020 年 10 月 20 日
編集済み: Konrad Warner 2020 年 10 月 20 日
I'm wondering if there is a way to combine griddedInterpolants on the same grid.
I have uniform ngrids (201-by-201) for x and y and three different z-grids (surfaces) 201-by-201-by-3.
To querry all three z-values for a x-y-pair I can loop through three Interpolants but is there an faster/ smarter way?
% Show plots
surf(xGrid,yGrid,zGrid(:,:,1))
surf(xGrid,yGrid,zGrid(:,:,2))
surf(xGrid,yGrid,zGrid(:,:,3))
% Interpolant for each z-surface
C(1).F = griddedInterpolant(xGrid,yGrid,zGrid(:,:,1));
C(2).F = griddedInterpolant(xGrid,yGrid,zGrid(:,:,2));
C(3).F = griddedInterpolant(xGrid,yGrid,zGrid(:,:,3));
% Querry points, eg
x = 4;
y = -1;
for i = 1 : 3
out(i) = C(i).F(x,y);
end

採用された回答

Steve Eddins
Steve Eddins 2020 年 10 月 20 日
I don't think so. If you have a large number of query points, you might try replacing the Values property of the griddedInterpolant for each of the three planes in your grid, instead of creating three different griddedInterpolant objects.
F = griddedInterpolant(xGrid,yGrid,zGrid(:,:,1));
out{1} = F(xx,yy);
F.Values = zGrid(:,:,2);
out{2} = F(xx,yy);
F.Values = zGrid(:,:,3);
out{3} = F(xx,yy);
I'm not sure if this will actually execute faster, though.
The MATLAB Math team is aware of this workflow and is considering ways to improve it.
  1 件のコメント
Konrad Warner
Konrad Warner 2020 年 10 月 20 日
Ok thanks anyway

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

その他の回答 (1 件)

Bruno Luong
Bruno Luong 2020 年 10 月 20 日
If you know in advande the reference gridded points and the query points, (but the z data change), you migh build one ce interpolation matrix, then multiply by the data to retrieve the interpolation values. See this thread
  1 件のコメント
Konrad Warner
Konrad Warner 2020 年 10 月 20 日
編集済み: Konrad Warner 2020 年 10 月 20 日
It's more that the zData are constant and the querry points change.
It's a classifier: Each surface (3rd dimension) represants a class and I want to find the degree of membership (zValues) to each class for the Features x and y.

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

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by