Main Content


Validate that setting value is a logical scalar

Since R2019b



matlab.settings.mustBeLogicalScalar(settingvalue) issues an error if settingvalue is not a logical 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.


collapse all

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

Create the settings group mysettings.

s = settings;

Add the setting MyLogicalSetting to mysettings and specify the validation function matlab.settings.mustBeLogicalScalar.


Test the validation function. Set the value of MyLogicalSetting to a nonlogical value. As expected, MATLAB® throws an error.

s.mysettings.MyLogicalSetting.PersonalValue = 'Hello';
Error setting 'MyLogicalSetting' in group 'mysettings': Value must be logical.

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