Alternative function to scatteredInterpolant

12 Ansichten (letzte 30 Tage)
Alejandro Fernández
Alejandro Fernández am 29 Jul. 2021
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.

Akzeptierte Antwort

KSSV
KSSV am 29 Jul. 2021
Have a look on griddata.
  3 Kommentare
KSSV
KSSV am 29 Jul. 2021
griddata works though.
Alejandro Fernández
Alejandro Fernández am 4 Aug. 2021
You were rigth, thank you so much

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by