1D griddedInterpolant with 2D query points, does not work?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I'm trying to use griddedInterpolant with nD grid sizes, and ND query point matrices, where nD does not equal ND. This works well, except when I define a 1D griddedInterpolant, and have 2D or higher dimensional query point matrices.
See below for an example. The provided code works without error in 2014b, the commented lines give an error when uncommented.
Is there an alternative way of programming this, where I can treat the 1D case the same as the general case?
x = 1:8;
V1 = rand(1,8);
V2 = rand(8,8);
V3 = rand(8,8,8);
I1 = griddedInterpolant({x},V1);
I2 = griddedInterpolant({x,x},V2);
I3 = griddedInterpolant({x,x,x},V3);
X1 = ones(1,3);
X2 = ones(3,3);
X3 = ones(3,3,3);
I1(X1)
I2(X1,X1)
I3(X1,X1,X1)
% I1(X2)
I2(X2,X2)
I3(X2,X2,X2)
% I1(X3)
I2(X3,X3)
I3(X3,X3,X3)
0 commentaires
Réponses (1)
Richa Gupta
le 21 Juil 2015
Hi Chris,
For creating a 1-D interpolant object, you can pass x, a set of points, and v, a vector of the same length containing the corresponding values.
F = griddedInterpolant(x,v)
Now when you query the Interpolant, the griddedInterpolant, F, is evaluated in the same way as you would call a function. So, you cannot have 2D or higher dimensional query points but only a vector or a 1D matrix. The commented lines throwing an error is the expected behavior because you are first passing a 2D (X2) query point and then a 3D (X3) query point to the 1D griddedInterpolant “I1” that you created.
Hope this helps.
Richa
Voir également
Catégories
En savoir plus sur Interpolation 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!