Matlab arguments validation

Matlab arguments validation syntax is generally recommended over the legacy validateattributes. The arguments specification coerces the data to fix 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.


A downside of the Matlab argument validation syntax is that they are enacted at runtime, so repeated specification may entail increased CPU burden. It seems that Matlab JIT could optimize these away.