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.

Caveats

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.

It appears that Octave 7.x might be adding the ability to ignore the arguments syntax until the functionality is added to Octave. Older versions of Octave simply error if arguments syntax is used.