matlab.settings.mustBeIntegerScalar

Validation function that errors unless the value is an integer scalar.

Category: Environment and Settings > System Commands

Syntax

matlab.settings.mustBeIntegerScalar(v)

Returns silently if v is an integer 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.mustBeIntegerScalar). 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.mustBeIntegerScalar(3)
disp('accepted')
try
    matlab.settings.mustBeIntegerScalar(2.5)
catch err
    disp(err.message)
end
Output
accepted
Value must be an integer.

See also

addSetting matlab.settings.mustBeLogicalScalar matlab.settings.mustBeNumericScalar matlab.settings.mustBeStringScalar