addOptional
Add optional, positional argument into input parser scheme
Description
addOptional(
adds an optional, positional input argument, p,argName,defaultVal)argName, into the
input parser scheme p. When the inputs to a function do not
include a value for this optional input, the input parser assigns it the value
defaultVal.
addOptional(
specifies a validation function for the input argument.p,argName,defaultVal,validationFcn)
Examples
Input Arguments
Tips
Arguments added to the input parser scheme with the
addOptionalfunction are positional. Therefore, add them to the input parser scheme in the same order they are passed into the function.For optional string arguments, specify a validation function. Without a validation function, the input parser interprets a string argument as an invalid parameter name and throws an error.
Use
addOptionalto add an individual argument into the input parser scheme. If you want to parse an optional name-value pair, then use theaddParameterfunction.
Version History
Introduced in R2007a