Set system and block parameter values
set_param(
sets the parameter to the specified value on the specified model or block object.Object
,ParameterName
,Value
,...ParameterNameN,ValueN)
When you set multiple parameters on the same model or block, use a singleset_param
command with multiple pairs ofParameterName
,Value
arguments, rather than multipleset_param
commands. This technique is efficient because using a single call requires evaluating parameters only once. If any parameter names or values are invalid, then the function doesn’t set any parameters.
Tips:
If you make multiple calls toset_param
for the same block, then specifying the block using a numeric handle is more efficient than using the full block path. UsegetSimulinkBlockHandle
to get a block handle.
If you usematlab -nodisplay
to start a session, you cannot useset_param
to run your simulation. The-nodisplay
mode does not support simulation usingset_param
. Use thesim
command instead.
After you set parameters in the MATLAB®workspace, to see the changes in a model, update the diagram.
set_param(model,'SimulationCommand','Update')
For parameter names, see: