# Alternative function to scatteredInterpolant

8 visualizaciones (últimos 30 días)
Alejandro Fernández el 29 de Jul. de 2021
Comentada: Alejandro Fernández el 4 de Ag. de 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.
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

KSSV el 29 de Jul. de 2021
Have a look on griddata.
##### 3 comentariosMostrar 1 comentario más antiguoOcultar 1 comentario más antiguo
KSSV el 29 de Jul. de 2021
griddata works though.
Alejandro Fernández el 4 de Ag. de 2021
You were rigth, thank you so much

Iniciar sesión para comentar.

### Categorías

Más información sobre Interpolation en Help Center y File Exchange.

R2021a

### Community Treasure Hunt

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

Start Hunting!

Translated by