Documentation Center

  • Trial Software
  • Product Updates

set_param

Set system and block parameter values

Syntax

  • set_param(object,param,value) example
  • set_param(object,param1,value1,...,paramN,valueN) example

Description

example

set_param(object,param,value) sets the parameter to the specified value on the specified model or block object.

example

set_param(object,param1,value1,...,paramN,valueN) sets parameters and values on the specified model or block object.

When you set multiple parameters on the same model or block, use a single set_param command with multiple pairs of arguments, rather than multiple set_param commands. This technique is efficient because using a single call requires evaluating parameters only once. It is more robust because it prevents dependency errors by setting all parameter values before checking the legality of the results.

    Note:   If you use matlab -nodisplay to start a session, you cannot use set_param to run your simulation. The -nodisplay mode does not support menu simulation.

    Tip   After you set parameters in the MATLAB® workspace, in the Simulink® editor, use Simulation > Update Diagram to see the changes in a model.

Examples

expand all

Set Model Configuration Parameters for the vdp System

Set the Solver and StopTime parameters of the vdp system. Open vdp first.

vdp
set_param('vdp','Solver','ode15s','StopTime','3000')

Set Model Configuration Parameters for Current System

Set the Solver and StopTime parameters of the current system. Open a model first.

vdp
set_param(gcs,'Solver','ode15s','StopTime','3000')

Set Position of Block

Set the position of the Fcn block in the vdp system. Open vdp first.

vdp
set_param('vdp/Fcn','Position',[50 100 110 120])

Input Arguments

expand all

object — Object namestring

Object name of a model or path and name of a block.

Example: 'vdp/Fcn'

param — Parameterstring

Parameter name, specified as a string. Case is ignored for parameter names. Value strings are case sensitive.

Many block parameter values must be specified as strings.

Example: 'Position',[50 100 110 120]

value — Parameter valuedetermined by parameter

Parameter value, specified in the format determined by the parameter. Values are often strings, but they can also be numeric, arrays, and so on. Value strings are case sensitive.

Many block parameter values are specified as strings. Two exceptions are the Position, specified as a vector, and UserData, specified according to the user data, parameters. These parameters are common to all blocks.

Example: 'Solver','ode15s','StopTime','3000'

Example: 'SimulationCommand', 'start'

Example: 'Position',[50 100 110 120]

See Also

|

Was this topic helpful?