mphsetparam
Set parameter values.
Syntax
mphsetparam(model, name, value, description)
mphsetparam(model, name, [])
mphsetparam(model, data_cellarray)
mphsetparam(model, data_struct)
mphsetparam(model, data_dictionary)
Description
mphsetparam(model, name, value) sets a parameter with name to value. value can be a string or a scalar variable (real or complex). If a unit must be supplied then value has to be a string. If the parameter does not already exist, it is created. If the parameter exists its description is not changed.
The name can be a simple parameter name (such as 'L')
The name can be used to define parameter groups by joining the group name and the parameter name with a slash (/).
The name can be used to define parameter cases by joining the group name, parameter case name and parameter name with slashes (/).
mphsetparam(model, name, value, description) sets the parameter name to value using the description.
mphsetparam(model, name, []) deletes the parameter name.
mphsetparam(model, data_cellarray) sets the parameters defined in data_cellarray that must contain an even number of elements with pairs of parameter names and values.
mphsetparam(model, data_struct) sets the parameters defined in data_struct using the fieldnames as parameter names and the struct values as values for the parameters.
mphsetparam(model, data_dictionary) sets the parameters defined in data_dictionary using the keys as parameter names and the dictionary values as values for the parameters.
Example
Set value in model.param:
mphsetparam(model, 'L', '9[cm]')
Also set description:
mphsetparam(model, 'L', '9[cm]', 'Length')
Remove 'L' by setting it to an empty matrix:
mphsetparam(model, 'L', [])
Set parameter values using a cell array:
cellarray = {'L' '9[cm]' 'wb' 0.09};
mphsetparam(model, cellarray)
Set parameter values using a struct:
param.L = '9[cm]';
param.wb = 0.05;
param.complex = 1+2i;
mphsetparam(model, param)
Set parameter values using a dictionary:
d = dictionary;
d("L") = 0.09;
d("wb") = 0.06;
mphsetparam(model, d)
Set the parameter L on parameter group group1:
mphsetparam(model, 'group1/L', '10[cm]')
Set values for the L parameter for two parameter cases:
mphsetparam(model, 'group/case1/L', '10[cm]')
mphsetparam(model, 'group/case2/L', '12[cm]')
See also
mphgetexpressions, mphevaluate