Input Parser Validation Functions - MATLAB & Simulink (original) (raw)

Main Content

This topic shows ways to define validation functions that you pass to the Input Parser to check custom function inputs.

The Input Parser methods addRequired, addOptional, and addParameter each accept an optional handle to a validation function. Designate function handles with an at (@) symbol.

Validation functions must accept a single input argument, and they must either return a scalar logical value (true or false) or error. If the validation function returns false, the Input Parser issues an error and your function stops processing.

There are several ways to define validation functions:

See Also

inputParser | validateattributes

More About