scatteredInterpolant gives out NaN in some query points
19 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Philipp
el 9 de Ag. de 2023
Comentada: Philipp
el 9 de Ag. de 2023
I have 3D-scattered testbench-data with x, y und z as setpoints and I want to make contourf-plots over x and y with z as adjustible parameter.
First i filtered and deleted doubled samples to make sure the datapoints are unique:
% Load Data
load('data.mat');
% Keep unique Data
setpoints = [data.x data.y data.z];
[setpointsu,idx] = unique(setpoints,'rows');
datau = data(idx,:);
Next I defined query-points which grid the room of the scattered data and interpolated:
xq = -50:5:0;
yq = 0:5:30;
zq = 25:5:75;
% Interpolieren
[Xq,Yq,Zq] = meshgrid(xq,yq,zq);
F.Value = scatteredInterpolant(x,y,z,datau.Value,'linear');
P.Value = F.Value(Xq,Yq,Zq);
But unfourtunately P.Value has some NaNs in the middle of the 'query room':
At these Points enough scattered input data should be availabe for interpolation.
What else could be causes for these red circled NaNs?
Thanks for your help.
0 comentarios
Respuesta aceptada
Bruno Luong
el 9 de Ag. de 2023
Editada: Bruno Luong
el 9 de Ag. de 2023
Probably your data contains NaN at one or several points.
I don't quite understand your code
datau.Value
seems not valid since datau = data(idx,:); looks like an array.
Please share your data.
6 comentarios
Bruno Luong
el 9 de Ag. de 2023
Editada: Bruno Luong
el 9 de Ag. de 2023
Clearly you have point outside the convexhull AND you have NaN in your data (double check is not enough, quadriple check may be)
load('data.mat')
% Keep unique Data
x=data.x;
y=data.y;
z=data.z;
setpoints = [data.x data.y data.z];
[setpointsu,idx] = unique(setpoints,'rows');
datau = data(idx,:);
xq = -50:5:0;
yq = 0:5:30;
zq = 25:5:75;
% Interpolieren
[Xq,Yq,Zq] = meshgrid(xq,yq,zq);
find(isnan(datau.Value))
F.Value = scatteredInterpolant(x,y,z,datau.Value,'linear');
P.Value = F.Value(Xq,Yq,Zq);
xq = -50:5:0;
yq = 0:5:30;
zq = 25:5:75;
% Interpolieren
[Xq,Yq,Zq] = meshgrid(xq,yq,zq);
F.Value = scatteredInterpolant(x,y,z,datau.Value,'linear','nearest');
P.Value = F.Value(Xq,Yq,Zq);
P.Value(:,:,4)
T=delaunayTriangulation(x,y,z);
F = convexHull(T);
close all
trisurf(F,x,y,z)
axis equal
hold on
plot3(Xq(:),Yq(:),Zq(:),'.')
Más respuestas (1)
Walter Roberson
el 9 de Ag. de 2023
By default, scatteredInterpolant with 'linear' method does not do extrapolation. If you attempt to query at a location that is outside the outside boundary of the triangulation of the reference points, then it would need extrapolation but that is not enabled by default for 'linear'
Ver también
Categorías
Más información sobre Data Distribution Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!