Effacer les filtres
Effacer les filtres

problem with scatteredInterpolant: are there any limits?

5 vues (au cours des 30 derniers jours)
Harald von der Osten
Harald von der Osten le 13 Nov 2022
Commenté : Star Strider le 14 Nov 2022
the xyz data file consists out of 3157394 data triples like this:
417826.974 5333045.048 1636.000
417826.974 5333045.128 1682.000
417826.974 5333045.208 1744.000
417826.974 5333045.288 1753.000
417826.974 5333045.368 1674.000
417826.974 5333045.448 1689.000
with the key data:
min(x) = 417740; max(x) = 417870; min(y) = 4177412; max(y)= 5333100; min(z)= 0; max(z) = 11054;
length(x) = length(y) = length(z) = 3157394;
First, everything works fine using:
TT=readtable(FileNameNeu,'PreserveVariableNames',true,'NumHeaderLines',1);
x=table2array(TT(:,1));
y=table2array(TT(:,2));
z=table2array(TT(:,3));
scatter3(x,y,z,4,z,'.'); view(2); grid on; daspect([1 1 1]);
But when I try this:
F = scatteredInterpolant(x,y,z,'natural','none'); :
[X,Y] = meshgrid(min(x):0.5:max(x),min(y):0.5:max(y));
Z = F(X,Y);
then I receive the error:
Error using scatteredInterpolant
The coordinates of the input points must be finite values; Inf and NaN are not
permitted.
Error in FillGaps (line 44)
F = scatteredInterpolant(x,y,z,'natural','none'); % create the interpolant
But...there are no Inf's and NaN's in the data file.
The same occurs if I reduce the values of x and z using:
x=x-min(x); y=y-min(y);
What I am doing wrong? Thanks a lot,
Harry
  5 commentaires
Harald von der Osten
Harald von der Osten le 14 Nov 2022
thanks a lot to all for your help. Finally Steven Lord's hint on anynan and allfinite helped a lot. Every some thousands line there was a text like "line xyz" in the datafile. Crazy.
Harald von der Osten
Harald von der Osten le 14 Nov 2022
417768.334 5333147.288 0.000
417768.334 5333147.368 0.000
417768.334 5333147.448 0.000
line 4177684
417768.414 5332990.328 0.000
417768.414 5332990.408 0.000
417768.414 5332990.488 0.000
417768.414 5332990.568 0.000

Connectez-vous pour commenter.

Réponse acceptée

Star Strider
Star Strider le 13 Nov 2022
Modifié(e) : Star Strider le 13 Nov 2022
It would help to have the file.
It appears to me that the data might be gridded. To determine that, the easiest way would be:
TT=readtable(FileNameNeu, 'VariableNamingRule','preserve')
x = TT{:,1};
y = TT{:,2};
z = TT{:,3};
[Ux,ixx] = unique(x)
RowSize = unique(ixx)
X = reshape(x,RowSize,[]);
Y = reshape(y,RowSize,[]);
Z = reshape(z,RowSize,[]);
figure
surf(X, Y, Z)
grid on
xlabel('X')
ylabel('Y')
zlabel('Z')
If that fails (the data not being gridded appropriately), try this —
L = size(TT,1);
xv = linspace(min(x), max(x), L);
yv = linspace(min(y), max(y), L);
[X,Y] = ndgrid(xv, yv);
Z = griddata(x, y, z, X, Y);
figure
surf(X, Y, Z)
grid on
xlabel('X')
ylabel('Y')
zlabel('Z')
One of those should work.
EDIT — (13 Nov 2022 at 23:52)
Corrected typographical errors.
.
  2 commentaires
Harald von der Osten
Harald von der Osten le 14 Nov 2022
thanks a lot for your efford. Finally, the error occured because of the text "line xyz" in the datafile....
Star Strider
Star Strider le 14 Nov 2022
As always, my pleasure!

Connectez-vous pour commenter.

Plus de réponses (1)

Bruno Luong
Bruno Luong le 13 Nov 2022
You'll have problem anyway since your data is not centered and especially not normalize.
x range is 130 and y range is 1155688, almost 10000 larger than xrange. Scattered interpolation is based on Delauray triangulation, and that alone will give garbage out.
I believe it written somewhere (tip) this warning in the doc page.
So please do CENTERING and NORMALIZATION data as preproceesing step before interpoltion.

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by