Is griddedinterpolant omits NaN?

36 visualizaciones (últimos 30 días)
BN
BN el 27 de Mzo. de 2020
Editada: Stephen23 el 2 de Dic. de 2024 a las 8:29
Hey all, I want to know when we using griddedinterpolant while we have some NaN in our data set, are they NaNs fills by griddedinterpolant? Or they remain as NaN?

Respuesta aceptada

darova
darova el 27 de Mzo. de 2020
You can find out by yourself
[X,Y] = meshgrid(0:10);
Z = 0*X;
Z(5:7,5:7) = nan;
surf(X,Y,Z,'edgecolor','none')
[X1,Y1] = meshgrid(0:0.4:10);
Z1 = griddata(X,Y,Z,X1,Y1);
hold on
surf(X1,Y1,Z1,'facecolor','none')
hold off
  1 comentario
Andrey Yatsunenko
Andrey Yatsunenko el 1 de Dic. de 2024 a las 20:35
I'm afraid the answer is incorrect.
Griddata is not a close relative to the griddedInterpolant; griddata (despite its name) deals with scattered data, and only up to 3 dimentions.

Iniciar sesión para comentar.

Más respuestas (1)

Stephen23
Stephen23 el 2 de Dic. de 2024 a las 5:50
Editada: Stephen23 el 2 de Dic. de 2024 a las 8:29
None of the pure interpolation routines will "omit" NaN values.
NaN values will propagate from input to output, just as they should in any mathematical calculation.
x = sort(20*rand(100,1));
v = besselj(0,x);
v(23:50) = NaN; % modified
F = griddedInterpolant(x,v)
F =
griddedInterpolant with properties: GridVectors: {[100x1 double]} Values: [100x1 double] Method: 'linear' ExtrapolationMethod: 'linear'
xq = linspace(0,20,500);
vq = F(xq);
plot(x,v,'ro')
hold on
plot(xq,vq,'.')
legend('Sample Points','Interpolated Values')
If you want to remove NaNs from data then you will need to either:
  • pre-process the data to remove the NaNs yourself, or
  • use high-level convenience functions e.g. FILLMISSING.

Categorías

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

Etiquetas

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by