Using Simulink | ![]() ![]() |
Set Simulink system and block parameters.
Syntax
set_param('obj', 'parameter1', value1, 'parameter2', value2, ...)
Description
set_param('obj', 'parameter1', value1, 'parameter2', value2, ...)
, where 'obj'
is a system or block path, sets the specified parameters to the specified values. Case is ignored for parameter names. Value strings are case sensitive. Any parameters that correspond to dialog box entries have string values. Model and block parameters are listed in Appendix A.
You can change block parameter values in the workspace during a simulation and update the block diagram with these changes. To do this, make the changes in the command window, then make the model window the active window, then choose Update Diagram from the Edit menu.
Note
Most block parameter values must be specified as strings. Two exceptions are the Position and UserData parameters, common to all blocks.
|
Examples
This command sets the Solver
and StopTime
parameters of the vdp
system.
set_param('vdp', 'Solver', 'ode15s', 'StopTime', '3000')
This command sets the Gain
parameter of block Mu in the vdp
system to 1000 (stiff).
set_param('vdp/Mu', 'Gain', '1000')
This command sets the position of the Fcn block in the vdp
system.
set_param('vdp/Fcn', 'Position', [50 100 110 120])
This command sets the Zeros
and Poles
parameters for the Zero-Pole block in the mymodel
system.
set_param('mymodel/Zero-Pole','Zeros','[2 4]','Poles','[1 2 3]')
This command sets the Gain
parameter for a block in a masked subsystem. The variable k
is associated with the Gain
parameter.
set_param('mymodel/Subsystem', 'k', '10')
This command sets the OpenFcn
callback parameter of the block named Compute
in system mymodel
. The function 'my_open_fcn'
executes when the user double-clicks on the Compute block. For more information, see Using Callback Routines.
set_param('mymodel/Compute', 'OpenFcn', 'my_open_fcn')
See Also
get_param, find_system
![]() | save_system | simulink | ![]() |