Main Content

matlab.settings.mustBeIntegerScalar

Validate that setting value is an integer scalar

Description

example

matlab.settings.mustBeIntegerScalar(settingvalue)issues an error ifsettingvalueis 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.

Examples

collapse all

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

Create the settings groupmysettings.

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

Add the settingMyIntegerSettingtomysettingsand specify the validation functionmatlab.settings.mustBeIntegerScalar.

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

Test the validation function. Set the value ofMyIntegerSettingto 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

collapse all

Setting value to validate, specified as a scalar of one of the following:

Other data types cause an error.

Version History

Introduced in R2019b