Matlab arguments validation

Matlab function arguments validation syntax is generally recommended over the legacy validateattributes() and inputParser() techniques. Function arguments validation specification coerces the input and/or output variables to the class declaration given if possible, and errors otherwise.

  • Default values are easily specified, which required such verbose syntax before.
  • only a single class can be specified
  • recall the .empty method of most Matlab classes e.g. datetime.empty() that allows initializing an empty array.

Matlab argument validation syntax coerces class at runtime.

An example of Matlab function argument validate on input and output arguments is in matlab-stdlib.