Griddata gives NaN values

43 Ansichten (letzte 30 Tage)
mehra
mehra am 21 Jun. 2020
Kommentiert: darova am 23 Jun. 2020
Hello
In my code griddata gives NaN values, I checked if my query points are outside the convex hull of the sample data with the following code :
Xv=topologym_vert(:,1)/D;
Yv=topologym_vert(:,2)/D;
Zv=topologym_vert(:,3)/D;
ch=convhull(Xv,Zv)
plot(Xv(ch),Zv(ch),'r',xv,zv,'g')
and it seems everything is ok there,
So I wonder what else I have to change to get rid of NaN values?
the following is my code:
[xv,zv]=meshgrid(linspace((1/3),12,100),linspace(0.14,2.4,50));
aaa =
-0.0434 -0.0122 0.0507 0.2726 0.2433 0.2366 0.2452 -0.0344 -0.0225 0.0504 0.2446 0.2414
0.2426 0.2365 -0.0636 -0.0299 0.1221 0.2021 0.2335 0.2447 0.2399 -0.0342 -0.0002 0.0855
0.1676 0.2263 0.2327 0.2397 0.0827 0.0961 0.1150 0.1465 0.2199 0.2319 0.2346 0.0958
0.1031 0.1428 0.1659 0.2065 0.2332 0.2373 0.0896 0.0767 0.1249 0.1763 0.2160 0.2321
0.2334 0.1084 0.1224 0.1356 0.1621 0.2262 0.2353 0.0656 0.1133 0.1299 0.1539 0.2001
0.2315 0.2340 0.1426 0.1399 0.1321 0.2093 0.2289 0.1369 0.1675 0.1644 0.2151 0.2308
0.1828 0.1668 0.1648 0.1755 0.2038 0.2264 0.2319 0.2012 0.1875 0.2016 0.1872 0.2070
0.2210 0.2334
uvD=griddata(Xv,Zv,aaa,xv,zv);
Xv and Zv are attached.
Thanks.
  2 Kommentare
mehra
mehra am 21 Jun. 2020
Bearbeitet: mehra am 21 Jun. 2020
yes Yv is not necessary here
I attached the actual data for Xv and Zv in my original question
thanks

Melden Sie sich an, um zu kommentieren.

Antworten (1)

darova
darova am 22 Jun. 2020
I think you are using griddata in a wrong way
clc,clear
load Xv.mat
load Zv.mat
load data.txt
xx = linspace(min(Xv),max(Xv),20);
zz = linspace(min(Zv),max(Zv),20);
[xv,zv] = meshgrid(xx,zz); % create 2d mesh
yv = griddata(Xv,Zv,data,xv,zv); % interpolate data
plot3(Xv,Zv,data,'.r')
surface(xv,zv,yv)
axis vis3d
  2 Kommentare
darova
darova am 23 Jun. 2020
Don't see NaN

Melden Sie sich an, um zu kommentieren.

Kategorien

Find more on Interpolation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by