matlab.settings.mustBeNumericScalar - Validate that setting value is a numeric scalar - MATLAB (original) (raw)

Main Content

Validate that setting value is a numeric scalar

Syntax

Description

matlab.settings.mustBeNumericScalar([settingvalue](#mw%5Ffa482009-1321-4e43-8cb4-f83b69cbb3ca)) issues an error if settingvalue is not a numeric 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 a numeric scalar.

Create the settings group mysettings.

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

Add the setting MyNumericSetting tomysettings and specify the validation functionmatlab.settings.mustBeNumericScalar.

addSetting(s.mysettings,'MyNumericSetting','ValidationFcn',@matlab.settings.mustBeNumericScalar);

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

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

Error setting 'MyNumericSetting' in group 'mysettings': Value must be numeric.

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