set_param - Set Simulink® system and block parameters

Syntax

set_param('obj', 'parameter1', value1, 'parameter2', value2, ...)
set_param(0, 'modelparm1', value1, 'modelparm2', 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. Value strings are case sensitive. Case is ignored for parameter names. Any parameters that correspond to dialog box entries have string values. Model and block parameters are listed in Model and Block Parameters.

set_param(0, 'modelparm1', value1, 'modelparm2', value2, ...) sets the specified model parameters to default values, i.e., to values that Simulink software assigns to the parameters when it creates a model. You can use this form of set_param in your MATLAB® startup file to specify your own default values for Simulink model parameters.

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.

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.

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 you double-click on the Compute block (see Using Callback Functions).

set_param('mymodel/Compute', 'OpenFcn', 'my_open_fcn')

See Also

find_system, get_param

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS