"Invalid interpolation method" after moving to MATLAB2020b

This code was working well using MATLAB2018a:
z_t = interp1(time,x,y,'splines')
In MATLAB2020b, it is showing these error:
Error using interp1>sanitycheckmethod (line 285)
Invalid interpolation method.
Error in interp1>parseinputs (line 393)
method = sanitycheckmethod(last);
Error in interp1 (line 112)
parseinputs(X,V,penultimate,last,nargin,ndataarg,pp);

1 comentario

Andrea Pirlo — See my Answer (and Vote for it if it solves your problem)!

Iniciar sesión para comentar.

 Respuesta aceptada

Star Strider
Star Strider el 20 de Feb. de 2021
See method in the interp1 documentation (R2020b, however I doubt if it’s changed significantly since R2018b).

7 comentarios

Yousef Dajani
Yousef Dajani el 20 de Feb. de 2021
Editada: Yousef Dajani el 20 de Feb. de 2021
It looks like there was a typo: "spline" instead of "splines".
Weird that it ran on MATLAB2018a!
Anyway, I corrected the typo. Thanks for your answer!
As always, my pleasure!
My guess is if it worked in the past, they changed something, making it slightly more picky.
The property has always been just 'spline' as far back as I can remember. Therefore, this was arguably a bug fix, making the code consistent with the documenttion, and as the docs have always been.
I would have to go back and check but I suspect the refactoring that improved performance in release R2020a brought with it stricter input argument checking.
Will Reeves
Will Reeves el 10 de Abr. de 2025
Editada: Will Reeves el 10 de Abr. de 2025
In my case I see an error with "linear" interpolation but see the same error message:
pp = interp1(x,v,'linear','pp');
I've just had to resurrect some old code, and find it irratating that seemingly basic functionality has changed even though I've changed nothing. What's particularly unhelpful is the lack of good quality error messages. "Invalid interpolation method". Well, it used to work, and it seems as though the documentation hasn't changed from my usage so what is the problem?
I do notice that there is an "orange squiggle" hinting that using piecewise polynomial is "not recommended" and to use "griddedInterpolant" instead though.
______________________________________
Hilarious! I made exactly the same mistake... nearly... I wrote "liner" and not "linear"! Apologies!
@Will Reeves looks to me as if it works
x = 1:5;
v = rand(1,5);
pp = interp1(x,v,'linear','pp');
pp
pp = struct with fields:
form: 'pp' breaks: [1 2 3 4 5] coefs: [4x2 double] pieces: 4 order: 2 dim: 1 orient: 'first'
Will Reeves
Will Reeves el 11 de Abr. de 2025
Editada: Will Reeves el 11 de Abr. de 2025
Hi, yes it does... but not when you spell "linear", "liner" (like I did!) - although it's interesting that it used to work. Perhaps the function just used to compare the first few letters of the method or something. Anyway, it was my fault! Apologies!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Interpolation en Centro de ayuda y File Exchange.

Preguntada:

el 20 de Feb. de 2021

Editada:

el 11 de Abr. de 2025

Community Treasure Hunt

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

Start Hunting!

Translated by