problem with scatteredInterpolant: are there any limits?

조회 수: 9 (최근 30일)
Harald von der Osten
Harald von der Osten 2022년 11월 13일
댓글: Star Strider 2022년 11월 14일
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
Harald von der Osten
Harald von der Osten 2022년 11월 14일
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 2022년 11월 14일
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

댓글을 달려면 로그인하십시오.

채택된 답변

Star Strider
Star Strider 2022년 11월 13일
편집: Star Strider 2022년 11월 13일
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
Harald von der Osten
Harald von der Osten 2022년 11월 14일
thanks a lot for your efford. Finally, the error occured because of the text "line xyz" in the datafile....
Star Strider
Star Strider 2022년 11월 14일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Bruno Luong
Bruno Luong 2022년 11월 13일
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.

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by