set_param
R2026bSet Simulink parameter value
Description
set_param(
sets the specified parameter value for the target object. For example, you can use
this syntax to change the amplitude value of a Sine Wave block. The
target object can be a model, subsystem, library, block, line, port, or bus element
port element specified as a handle or path. For information on how to get handles
and paths, see Get Handles and Paths.object,parameter1=value1,...,parameterN=valueN)
To set multiple parameter values for the target object, call the
set_param function once with multiple name-value arguments
instead of separately calling the function for each parameter. Setting multiple
parameters with one function call is faster because one call evaluates the
parameters only once. If any parameter names or values are invalid, then the
function does not set any parameters.
To programmatically interact with a simulation, use the
set_param function with the
SimulationCommand name-value argument. For more information,
on the page Run Simulations Programmatically, see the section Interact with Simulations by Issuing Simulation Commands.
For most parameters, running set_param regardless of whether
the specified value is different from the current value is faster than comparing the
values and only running the function if the values differ.
Changing a parameter value using the set_param function
dirties the model, even when the parameter only changes a mode. For example,
changing the variant control mode by setting the value of the
LabelModeActiveChoice parameter dirties the model.
Examples
Input Arguments
Limitations
If you use
matlab -nodisplayto start a session, you cannot useset_paramto run a simulation. The-nodisplaymode does not support simulation usingset_param. Use thesimfunction instead.When you use the
set_paramfunction to rename a block or signal, these names are not valid: empty names, names that contain only newline characters, and names that begin or end with/.
Version History
Introduced before R2006a
See Also
Functions
get_param|getSimulinkBlockHandle|gcs|gcb|bdroot|open_system|new_system