How can I use interp2 with 1 query point?

4 visualizaciones (últimos 30 días)
Filippo Gallucci
Filippo Gallucci el 8 de Oct. de 2022
Editada: dpb el 8 de Oct. de 2022
Following the code. I can't understand what is the problem. Thank you in advance!
Is there a better method to do this type of interpolation?
s=0.12;
hth=1.23;
s_ls=[0 0.03 0.05 0.1 0.15 0.2 0.25];
hth_ls=[0.2 0.4 0.6 0.8 0.1];
k1_ls_02=[1 1 1.6 2.8 4.45 5.5 6.25]; %values of k1 for ht/h=0.2
k1_ls_04=[1 1 1.5 2.6 3.5 4.45 5.3]; %values of k1 for ht/h=0.4 and s
k1_ls_06=[1 1 1.3 1.75 2.6 3.4 3.65]; %values of k1 for ht/h=0.6
k1_ls_08=[1 1 1.2 1.5 1.9 2.15 2.3]; %values of k1 for ht/h=0.8
k1_ls_10=[1 1 1 1 1 1 1]; %values of k1 for ht/h=1.0
k1_ls=[k1_ls_02; k1_ls_04; k1_ls_06; k1_ls_08; k1_ls_10];
[s_ls_matrix,hth_ls_matrix]=meshgrid(s_ls,hth_ls);
k1=interp2(s_ls_matrix,hth_ls_matrix,k1_ls,s,hth);
Error using griddedInterpolant
Sample points must be sorted in ascending order.

Error in interp2>makegriddedinterp (line 226)
F = griddedInterpolant(varargin{:});

Error in interp2 (line 134)
F = makegriddedinterp(X, Y, V, method,extrap);
  2 comentarios
dpb
dpb el 8 de Oct. de 2022
Editada: dpb el 8 de Oct. de 2022
hth_ls=[0.2 0.4 0.6 0.8 0.1];
Is the above a typo, I'm guessing? Either the 0.1 was intended as 1.0 or it is misplaced at the end of the vector instead of the beginning.
Torsten
Torsten el 8 de Oct. de 2022
Furthermore, you try to extrapolate to a value of 1.23 for hth (values are only given k1_ls are only give for 0.2 <= hth_ls <= 1).
interp2 will return NaN in this case.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Array Geometries and Analysis en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by