matlab.settings.mustBeStringScalar

Validation function that errors unless the value is a string scalar or character vector.

Category: Environment and Settings > System Commands

Syntax

matlab.settings.mustBeStringScalar(v)

Returns silently if v is a string scalar or character vector; 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.mustBeStringScalar). 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.mustBeStringScalar("abc")
disp('accepted')
try
    matlab.settings.mustBeStringScalar(42)
catch err
    disp(err.message)
end
Output
accepted
Value must be a string scalar.

See also

addSetting matlab.settings.mustBeIntegerScalar matlab.settings.mustBeLogicalScalar matlab.settings.mustBeNumericScalar