setpref - Set custom setting value - MATLAB (original) (raw)

Syntax

Description

setpref([group](#d126e1663035),[pref](#d126e1663069),[value](#d126e1663117)) sets the specified setting in the specified group to the specified value. If the setting or group does not exist, MATLAB® creates it.

Settings are persistent and maintain their values between MATLAB sessions.

example

Examples

collapse all

Create a setting group and setting and then change the setting value.

Use addpref to create a setting group calledmytoolbox and add a setting within it calledversion.

addpref('mytoolbox','version','1.0')

Change the value of the version setting and then get the setting value.

setpref('mytoolbox','version',{'1.0','beta'}) getpref('mytoolbox','version')

ans = 1×2 cell array {'1.0'} {'beta'}

Input Arguments

collapse all

Custom setting group name, specified as a character vector or a string scalar. group must be a valid variable name. For more information, see Variable Names.

Example: 'mytoolbox'

Data Types: char | string

Custom setting name, specified as a character vector, a cell array of character vectors, or a string array. pref must be a valid variable name. For more information, see Variable Names.

If pref is a cell array of character vectors or a non-scalar string, value must specify a value for each setting specified in pref.

Example: 'version'

Example: {'version','modifieddate','docpath'}

Data Types: char | string

Custom setting value, specified as any MATLAB data type, including numeric types, character vectors, cell arrays, structures, and objects. If pref is a cell array of character vectors or a nonscalar string array, value must specify a value for each setting specified inpref.

Example: 1.1

Example: {{1.1,'beta'},datetime(2018,1,9),'C:\mytoolbox\documentation'}

Version History

Introduced before R2006a

expand all

The Preferences window has been renamed to the Settings window and preferences are now referred to as settings.