addParameter
Add parameter to sdo.ParameterSpace
or
sdo.GriddedSpace
object
Description
Examples
Add Parameters to Parameter Space Object
Create an sdo.ParameterSpace
object, ps
, for the Ac
parameter of the sdoHydraulicCylinder
model.
load_system('sdoHydraulicCylinder'); pAc = sdo.getParameterFromModel('sdoHydraulicCylinder','Ac'); ps = sdo.ParameterSpace(pAc);
Add the K
parameter to ps
.
pK = sdo.getParameterFromModel('sdoHydraulicCylinder','K'); ps = addParameter(ps,pK);
Add Parameter with Specified Distribution to Parameter Space Object
Create an sdo.ParameterSpace
object for the Ac
and C1
parameters of the sdoHydraulicCylinder
model.
load_system('sdoHydraulicCylinder'); p = sdo.getParameterFromModel('sdoHydraulicCylinder',{'Ac','C1'}); ps = sdo.ParameterSpace(p);
Add the K
parameter to ps
. Specify a normal distribution for K
.
pK = sdo.getParameterFromModel('sdoHydraulicCylinder','K'); pKdist = makedist('Normal','mu',pK.Value,'sigma',2); ps = addParameter(ps,pK,pKdist);
Add Parameters to Gridded Parameter Space
Since R2023a
Open the sdoCSTR
model and extract continuous parameters A
and h
. Assign values to these parameters for gridded sampling and define the parameter space.
mdl = "sdoCSTR"; open_system(mdl); p1 = sdo.getParameterFromModel(mdl,{'A','h'}); Avals = {0.2 0.6 1.0 1.4 1.8 2.2}; hvals = {0.5 1.5 2.5 3.5}; ps0 = sdo.GriddedSpace(p1,{Avals,hvals});
The sdoCSTR
model also contains parameters FeedCon0
and FeedTemp0
. Extract these parameters and define grid values for them.
p2 = sdo.getParameterFromModel(mdl,{'FeedCon0','FeedTemp0'}); Convals = {9.5 10.0 10.5}; Tempvals = {250,275,300};
Add these parameters to the gridded parameter space.
ps = addParameter(ps0,p2,{Convals,Tempvals})
ps = GriddedSpace with properties: ParameterValues: {{1x4 cell} {1x4 cell} {1x4 cell} {1x4 cell}} Notes: [] Spaces: {1x0 cell} ParameterNames: {'A' 'h' 'FeedCon0' 'FeedTemp0'} Options: [1x1 sdo.GriddingOptions]
addParameter
updates the ParameterNames
and ParameterValues
properties to reflect the new parameters.
Input Arguments
ps0
— Parameter space
sdo.ParameterSpace
object | sdo.GriddedSpace
object
Parameter space to add parameters to, specified as an
sdo.ParameterSpace
or sdo.GriddedSpace
object.
p
— Parameters to add
param.Continuous
object | param.Discrete
object | vector of parameter objects
Parameters to add to the parameter space, specified as a param.Continuous
object, a param.Discrete
object, or a vector of parameter objects.
If
ps0
is asdo.ParameterSpace
object, thenp
must contain only continuous parameters (param.Continuous
).If
ps0
is asdo.GriddedSpace
object, thenp
can contain continuous parameters (param.Continuous
) or discrete parameters (param.Discrete
).
Usually, you obtain ps0
using sdo.getParameterFromModel
or sdo.getStateFromModel
.
pdist
— Probability distribution of parameter values
probability distribution object | vector of probability distribution objects
Probability distribution of parameter values, specified as a univariate probability
distribution object or a vector of univariate probability distribution objects. Use this
argument when adding parameters for random sampling to an
sdo.ParameterSpace
object.
If
pdist
is a vector of the same length asp
, the software uses each entry ofpdist
as the probability distribution of the corresponding parameter inp
.If
pdist
contains only one distribution, the software uses this distribution as the probability distribution for all parameters inp
.
Use makedist
to create a univariate probability
distribution object. For example,
makedist('Normal','mu',10,'sigma',3)
.
To check if pdist
is a univariate distribution object, run
isa('pdist,'prob.UnivariateDistribution')
.
values
— Parameter values for gridded sampling
cell array of cell arrays
Since R2023a
Parameter values for gridded sampling, specified as a cell array of cell arrays
providing the allowed values for each parameter in p
. For instance,
if p
contains two parameters, one that can take values (1, 2, 3)
and another that can take values (10, 20, 30), then use values =
{{1,2,3},{10,20,30}}
. Use this argument when adding parameters for gridded
sampling to an sdo.GriddedSpace
object.
Output Arguments
ps
— Updated parameter space
sdo.ParameterSpace
object | sdo.GriddedSpace
object
Updated parameter space, returned as an sdo.ParameterSpace
or
sdo.GriddedSpace
object. addParameter
adds the
parameter or parameters specified in p
, setting
ps.ParameterNames
to reflect the names of the added parameters. The
function also updates the possible values for the new parameters depending on the type
of parameter space.
If ps0
is an sdo.ParameterSpace
object:
If you specify the
pdist
input argument, thenaddParameter
setsps.ParameterDistributions
to reflect the specified distributions for the new parameters.If you do not specify parameter distributions, then
addParameter
setsps.ParameterDistributions
with the default uniform distributions for the new parameters, setting the properties of the uniform distributions as follows for each parameter inp
:Lower
— Set top.Minimum
. Ifp.Minimum
is equal to-Inf
, then the software setsLower
to0.9*p.Value
. Ifp.Value
is equal to 0, then the software setsLower
to -1.Upper
— Set top.Maximum
. Ifp.Maximum
is equal toInf
, then the software setsUpper
to1.1*p.Value
. Ifp.Value
is equal to 0, then the software setsUpper
to 1.
If ps0
is an sdo.GriddedSpace
object:
If you specify the
values
input argument, thenaddParameter
setsps.ParameterValues
to reflect the specified grid values for the new parameters.If you do not specify values, then
addParameter
setsps.ParameterValues
to default values for each parameter inp
as follows:For each
param.Continuous
parameter inp
, the corresponding entry inps.ParameterValues
is set to{nom-10%,nom,nom+10%}
, wherenom
is the nonzero nominal value. If the nominal value is zero, then the default values are{-1,0,1}
.For each
param.Discrete
parameter inp
, the corresponding entry inps.ParameterValues
is set to theValueSet
property of the discrete parameter.
Tips
Use
addParameter
to add random parameters to randomly sampled parameter spaces or to add gridded parameters to gridded parameter spaces. To combine gridded parameters with random parameters, usecombine
.
Version History
Introduced in R2014aR2023a: Add parameters to gridded parameter space
The new syntax ps = addParameter(ps0,p,values)
lets you add
parameters with the specified grid values to a gridded parameter space (sdo.GriddedSpace
).
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)