帮助中心帮助中心
本页的翻译已过时。点击此处可查看最新英文版本。
验证值是标量或为空
mustBeScalarOrEmpty(value)
示例
如果 value 不是标量也不为空,则 mustBeScalarOrEmpty(value) 会引发错误。此函数不返回值。
value
mustBeScalarOrEmpty 调用以下函数来确定输入是否为标量或为空:
mustBeScalarOrEmpty
isscalar
isempty
全部折叠
使用 mustBeScalarOrEmpty 限制函数输入参数允许的值。
function v = buildVector(inc) arguments inc {mustBeScalarOrEmpty} end v = 1:inc:10; end
将非标量传递给 buildVector 函数会导致错误。
buildVector
v = buildVector([1 2]);
Error using buildVector v = buildVector([1 2]); ↑ Invalid argument at position 1. Value must be scalar.
要验证的值,指定为标量或空值。如果值不是标量也不为空,则会导致错误。
示例: []
[]
mustBeScalarOrEmpty 用于属性和函数参数验证。
arguments | mustBeNonempty
arguments
mustBeNonempty
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
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