Griddata doesn't reach sample points
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Chris Dizon
le 11 Juil 2023
Commenté : Chris Dizon
le 11 Juil 2023
Hello, I have 3 vectors I am using griddata to interpolate. The problem is that the sample points are not included in the griddata output as seen in the sample red dots in the image '20'; 20 corresponds to the amount of space between the points of linspace. If I increase this to 100 the sample points are eventually reached, but the resulting image is very crowded.
Any advice on how to get griddata to reach the sample points for a lower amount of linspace points?
Thanks
N = 20; %vs e.g.100
x = [8.53315129274914,9.30925339785209,8.53315129274914,9.30925339785209,9.30925339785209,9.30925339785209,9.30925339785209,4.45216152440796,3.79261956232135,3.79261956232135,17.0677590031963,17.0677590031963,4.09601048577567,5.68892934348203];
y = [1.32520094900129,1.32154631465502,1.19462692171560,1.24730173230503,1.10676794920524,1.09225969341119,0.815136578214699,0.757268342808360,1.01606958162158,0.942815599343300,0.675121536953220,0.693923408467932,1.15323471371613,1.62262286756171];
xvec = linspace(min(x), max(x), N);
yvec = linspace(min(y), max(y), N);
[X, Y] = meshgrid(xvec, yvec);
data = [53.3523658491640,73.0221175190515,66.4448159677658,53.0481929355336,34.9019870840489,27.0340993276701,388.109339785705,341.752595986306,561.738449969976,481.741285644030,93.8209397136714,36.7262731504483,538.496713957595,820.698548835111];
Z = griddata(x,y,data,X,Y);
figure
surf(X,Y,Z)
view(2)
hold on
plot3(x,y,data,'r.','MarkerSize',20)
0 commentaires
Réponse acceptée
the cyclist
le 11 Juil 2023
"For all interpolation methods other than "v4", the output vq contains NaN values for query points outside the convex hull of the sample data. The "v4" method performs the same calculation for all points regardless of location."
Using "v4", you will see points where you expected to originally:
N = 20; %vs e.g.100
x = [8.53315129274914,9.30925339785209,8.53315129274914,9.30925339785209,9.30925339785209,9.30925339785209,9.30925339785209,4.45216152440796,3.79261956232135,3.79261956232135,17.0677590031963,17.0677590031963,4.09601048577567,5.68892934348203];
y = [1.32520094900129,1.32154631465502,1.19462692171560,1.24730173230503,1.10676794920524,1.09225969341119,0.815136578214699,0.757268342808360,1.01606958162158,0.942815599343300,0.675121536953220,0.693923408467932,1.15323471371613,1.62262286756171];
xvec = linspace(min(x), max(x), N);
yvec = linspace(min(y), max(y), N);
[X, Y] = meshgrid(xvec, yvec);
data = [53.3523658491640,73.0221175190515,66.4448159677658,53.0481929355336,34.9019870840489,27.0340993276701,388.109339785705,341.752595986306,561.738449969976,481.741285644030,93.8209397136714,36.7262731504483,538.496713957595,820.698548835111];
Z = griddata(x,y,data,X,Y,"v4");
figure
surf(X,Y,Z)
view(2)
hold on
plot3(x,y,data,'r.','MarkerSize',20)
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Geometric Transformation and Image Registration dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!