matlab.settings.mustBeNumericScalar

Validation function that errors unless the value is a numeric scalar.

Category: Environment and Settings > System Commands

Syntax

matlab.settings.mustBeNumericScalar(v)

Returns silently if v is a numeric scalar; otherwise throws an error.

Description

These validators are meant as the 'ValidationFcn' of a setting, passed as a handle: addSetting(g, 'Size', 'ValidationFcn', @matlab.settings.mustBeNumericScalar). They produce no output on success and raise an error on failure, which makes the assignment to the setting fail. They can also be called directly.

Input arguments

v
Value to check.

Example

Accept and reject

matlab.settings.mustBeNumericScalar(2)
disp('accepted')
try
    matlab.settings.mustBeNumericScalar('a')
catch err
    disp(err.message)
end
Output
accepted
Value must be numeric.

See also

addSetting matlab.settings.mustBeIntegerScalar matlab.settings.mustBeLogicalScalar matlab.settings.mustBeStringScalar