# Alternative function to scatteredInterpolant

11 ビュー (過去 30 日間)
Alejandro Fernández 2021 年 7 月 29 日
Hello. I was wondering if anyone would know any alternative function to scatteredInterpolant (if possible that can be implemented also in Python) so that it can be equivalent to the one I show below.
function data_out = test_scatteredInterpolant (data_input)
U = rand(20,20);
V = rand(20,20);
[X,Y] = meshgrid(1:20,1:20);
% Create matrix with specific format.
aux_array = [reshape(U,[],1) reshape(V,[],1) reshape(X,[],1) reshape(Y,[],1)];
% Apply scatteredInterpolant with vector arrays.
FX = scatteredInterpolant(aux_array(:,1),aux_array(:,2), aux_array(:,3));
FY = scatteredInterpolant(aux_array(:,1),aux_array(:,2), aux_array(:,4));
% Apply FX and FY to the desired input.
data_out(:,1) = FX(data_input(:,1),data_input(:,2));
data_out(:,2) = FY(data_input(:,1),data_input(:,2));
end
Basically, the function constructs an interpolant for the matrices U,V,X and another for U,V,Y and then applies them to the points given as input, as the example below:
data_out = test_scatteredInterpolant(rand(10,2));
Note. The actual function does not work with random values but for the sake of an example I think it is more visual.

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

### 採用された回答

KSSV 2021 年 7 月 29 日
Have a look on griddata.
##### 3 件のコメント表示非表示 2 件の古いコメント
Alejandro Fernández 2021 年 8 月 4 日
You were rigth, thank you so much

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

R2021a

### Community Treasure Hunt

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

Start Hunting!

Translated by