Alternative function to scatteredInterpolant

20 vues (au cours des 30 derniers jours)
Alejandro Fernández
Alejandro Fernández le 29 Juil 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.

Réponse acceptée

KSSV
KSSV le 29 Juil 2021
Have a look on griddata.
  3 commentaires
KSSV
KSSV le 29 Juil 2021
griddata works though.
Alejandro Fernández
Alejandro Fernández le 4 Août 2021
You were rigth, thank you so much

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by