Why does MatLab has inputParse function but does not use it in its own functions

2 visualizaciones (últimos 30 días)
Why does MatLab has inputParse function but does not use it in its own functions, for example, in interp1 which accepts arguments in name-value style?
  3 comentarios
Rostislav Teryaev
Rostislav Teryaev el 5 de Jun. de 2018
Editada: Rostislav Teryaev el 5 de Jun. de 2018
Okay, it makes sense. But why do they offer it to users?
Stephen23
Stephen23 el 5 de Jun. de 2018
Editada: Stephen23 el 5 de Jun. de 2018
  • Demand.
  • Convenience.
  • For many users speed is not critical.

Iniciar sesión para comentar.

Respuestas (2)

Jan
Jan el 5 de Jun. de 2018
Editada: Jan el 5 de Jun. de 2018
The total time to solve a problem consists of:
T_total = T_design + T_programming + T_debugging + T_runtime
inputParser can reduce the programming time remarkably. It might waste many milliseconds, but if the function is called some hundred times only, this does not matter. Using an hour to write and test a variety of input arguments can be inefficient in comparison, even if the code consumes microseconds only. And if you have a bug in manual input parsing, which was not detected before delivering the software, the costs can be substantial.
The shorter the function and the more frequently it is called, the worse is the slowdown by inputParser. But even interp1 and polyfit need more time with checking the inputs than with the actual computations - without inputParser ...

Hilmar Lehnert
Hilmar Lehnert el 8 de Ag. de 2021
Because it's SLOW. For example, one undocumented sub function in pwelch() (psdfreqvec()) uses InputParser() and the darn thing chews up way more time than my entire data analysis which is a real problem for large data sets.
inputParser() is ok as an interface to a very high level function that gets called only a few times, but using it inside a library or utility function is a terrible idea.

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by