MATLAB Answers

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

조회 수: 6(최근 30일)
Rostislav Teryaev
Rostislav Teryaev 5 Jun 2018
편집: Jan 5 Jun 2018
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

Stephen Cobeldick
Stephen Cobeldick 5 Jun 2018
  • Because inputParse is slow: code is faster with custom input checking.
  • Because many toolbox functions call a compiled function to check the inputs, which is specialized for the family of functions that use it.
Rostislav Teryaev
Rostislav Teryaev 5 Jun 2018
Okay, it makes sense. But why do they offer it to users?
Stephen Cobeldick
Stephen Cobeldick 5 Jun 2018
  • Demand.
  • Convenience.
  • For many users speed is not critical.

댓글을 달려면 로그인하십시오.

답변(1개)

Jan
Jan 5 Jun 2018
편집: Jan 5 Jun 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 ...

  댓글 수: 0

댓글을 달려면 로그인하십시오.

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by