setpref
Set custom preference value
Description
Examples
Modify Preference Value
Create a preference group and preference and then change the preference value.
Use addpref
to create a preference group called
mytoolbox
and add a preference within it called
version
.
addpref('mytoolbox','version','1.0')
Change the value of the version
preference and then get
the preference value.
setpref('mytoolbox','version',{'1.0','beta'}) getpref('mytoolbox','version')
ans = 1×2 cell array {'1.0'} {'beta'}
Input Arguments
group
— Custom preference group name
character vector | string scalar
Custom preference 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
pref
— Custom preference name
character vector | cell array of character vectors | string array
Custom preference 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
preference specified in pref
.
Example: 'version'
Example: {'version','modifieddate','docpath'}
Data Types: char
| string
value
— Custom preference value
any MATLAB data type
Custom preference 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 preference specified in
pref
.
Example: 1.1
Example: {{1.1,'beta'},datetime(2018,1,9),'C:\mytoolbox\documentation'}
Version History
Introduced before R2006a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)