matlab.settings.mustBeIntegerScalar - Validate that setting value is an integer scalar - MATLAB (original) (raw)

Main Content

Validate that setting value is an integer scalar

Syntax

Description

matlab.settings.mustBeIntegerScalar([settingvalue](#mw%5Ff40c039c-dd46-40be-8da5-dab2b0c1a005)) issues an error if settingvalue is not an integer scalar. This function does not return a value.

This function ignores input arguments that are empty values. Therefore, no error is thrown when the setting value is empty.

example

Examples

collapse all

Create a setting and specify a function to validate that the setting value is an integer scalar.

Create the settings group mysettings.

s = settings; addGroup(s,'mysettings');

Add the setting MyIntegerSetting tomysettings and specify the validation functionmatlab.settings.mustBeIntegerScalar.

addSetting(s.mysettings,'MyIntegerSetting','ValidationFcn',@matlab.settings.mustBeIntegerScalar);

Test the validation function. Set the value ofMyIntegerSetting to a noninteger value. As expected, MATLABĀ® throws an error.

s.mysettings.MyIntegerSetting.PersonalValue = 'Hello';

Error setting 'MyIntegerSetting' in group 'mysettings': Value must be integer.

Input Arguments

Version History

Introduced in R2019b