DocumentationHelp Center
Validate that value is scalar or empty
mustBeScalarOrEmpty(value)
example
mustBeScalarOrEmpty(value)throws an error ifvalue不是一个标量或不是空的。这个函数能源部s not return a value.
value
mustBeScalarOrEmptycalls the following function to determine if the input is scalar or empty:
mustBeScalarOrEmpty
isscalar
isempty
collapse all
UsemustBeScalarOrEmptyto restrict the values allowed for a function input argument.
functionv = buildVector(inc)argumentsinc{mustBeScalarOrEmpty}endv = 1:inc:10;end
Passing a nonscalar to thebuildVectorfunction 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:[]
[]
mustBeScalarOrEmptyis designed to be used for property and function argument validation.
arguments|mustBeNonempty
arguments
mustBeNonempty
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select:.
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office