Validate that value is scalar or empty
mustBeScalarOrEmpty(value)
example
mustBeScalarOrEmpty(value) throws an error if value is not a scalar or is not empty. This function does not return a value.
value
mustBeScalarOrEmpty calls the following function to determine if the input is scalar or empty:
mustBeScalarOrEmpty
isscalar
isempty
collapse all
Use mustBeScalarOrEmpty to restrict the values allowed for a function input argument.
function v = buildVector(inc) arguments inc {mustBeScalarOrEmpty} end v = 1:inc:10; end
Passing a nonscalar to the buildVector function results in an error.
buildVector
v = buildVector([1 2]);
Error using buildVector Invalid argument at position 1. Value must be scalar.
Value to validate, specified as a scalar or an empty value. Values that are not a scalar or are not empty result in an error.
Example: []
[]
mustBeScalarOrEmpty is designed to be used for property and function argument validation.
arguments | mustBeNonempty
arguments
mustBeNonempty