addParameter
R2026bAdd parameter to sdo.ParameterSpace or
sdo.GriddedSpace object
Description
Examples
The CSTR subsystem block in the sdoCSTR model includes the parameters A and F.
Create an sdo.ParameterSpace object, ps, for the A parameter.
load_system("sdoCSTR"); pA = sdo.getParameterFromModel("sdoCSTR","A"); ps = sdo.ParameterSpace(pA)
ps =
ParameterSpace with properties:
ParameterDistributions: [1×1 prob.UniformDistribution]
RankCorrelation: []
Notes: []
ParameterNames: {'A'}
Options: [1×1 sdo.SampleOptions]
Add the F parameter to ps.
pF = sdo.getParameterFromModel("sdoCSTR","F"); ps = addParameter(ps,pF)
ps =
ParameterSpace with properties:
ParameterDistributions: [1×2 prob.UniformDistribution]
RankCorrelation: []
Notes: []
ParameterNames: {'A' 'F'}
Options: [1×1 sdo.SampleOptions]
The CSTR subsystem block in the sdoCSTR model includes the parameters A, F, and h.
Create an sdo.ParameterSpace object for the A and F parameters.
load_system("sdoCSTR"); p = sdo.getParameterFromModel("sdoCSTR",{'A','F'}); ps = sdo.ParameterSpace(p)
ps =
ParameterSpace with properties:
ParameterDistributions: [1×2 prob.UniformDistribution]
RankCorrelation: []
Notes: []
ParameterNames: {'A' 'F'}
Options: [1×1 sdo.SampleOptions]
Add the h parameter to ps. Specify a normal distribution for h.
ph = sdo.getParameterFromModel("sdoCSTR","h"); phdist = makedist("Normal",mu=ph.Value,sigma=2); ps = addParameter(ps,ph,phdist)
ps =
ParameterSpace with properties:
ParameterDistributions: [1×3 prob.ToolboxParametricDistribution]
RankCorrelation: []
Notes: []
ParameterNames: {'A' 'F' 'h'}
Options: [1×1 sdo.SampleOptions]
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: {{1×6 cell} {1×4 cell} {1×3 cell} {1×3 cell}}
Notes: []
Spaces: {1×0 cell}
ParameterNames: {'A' 'h' 'FeedCon0' 'FeedTemp0'}
Options: [1×1 sdo.GriddingOptions]
addParameter updates the ParameterNames and ParameterValues properties to reflect the new parameters.
Input Arguments
Parameter space to add parameters to, specified as an
sdo.ParameterSpace or sdo.GriddedSpace
object.
Parameters to add to the parameter space, specified as a param.Continuous object, a param.Discrete
object, or a vector of parameter objects.
If
ps0is asdo.ParameterSpaceobject, thenpmust contain only continuous parameters (param.Continuous).If
ps0is asdo.GriddedSpaceobject, thenpcan contain continuous parameters (param.Continuous) or discrete parameters (param.Discrete).
Usually, you obtain ps0 using sdo.getParameterFromModel or sdo.getStateFromModel.
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
pdistis a vector of the same length asp, the software uses each entry ofpdistas the probability distribution of the corresponding parameter inp.If
pdistcontains 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').
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
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
pdistinput argument, thenaddParametersetsps.ParameterDistributionsto reflect the specified distributions for the new parameters.If you do not specify parameter distributions, then
addParametersetsps.ParameterDistributionswith 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.Minimumis equal to-Inf, then the software setsLowerto0.9*p.Value. Ifp.Valueis equal to 0, then the software setsLowerto -1.Upper— Set top.Maximum. Ifp.Maximumis equal toInf, then the software setsUpperto1.1*p.Value. Ifp.Valueis equal to 0, then the software setsUpperto 1.
If ps0 is an sdo.GriddedSpace object:
If you specify the
valuesinput argument, thenaddParametersetsps.ParameterValuesto reflect the specified grid values for the new parameters.If you do not specify values, then
addParametersetsps.ParameterValuesto default values for each parameter inpas follows:For each
param.Continuousparameter inp, the corresponding entry inps.ParameterValuesis set to{nom-10%,nom,nom+10%}, wherenomis the nonzero nominal value. If the nominal value is zero, then the default values are{-1,0,1}.For each
param.Discreteparameter inp, the corresponding entry inps.ParameterValuesis set to theValueSetproperty of the discrete parameter.
Tips
Use
addParameterto 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 R2014aThe 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.
Seleccione un país/idioma
Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .
También puede seleccionar uno de estos países/idiomas:
Cómo obtener el mejor rendimiento
Seleccione China (en idioma chino o inglés) para obtener el mejor rendimiento. Los sitios web de otros países no están optimizados para ser accedidos desde su ubicación geográfica.
América
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- 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)