Contenido principal

add_param

R2026b

Add parameter to Simulink model

Description

add_param(sys,param1=val1,...,paramN=valN) adds the specified parameters to the specified model and initializes the parameters to the specified values. The parameters are saved in the corresponding SLX or MDL file. You can use the set_param and get_param functions on the parameters.

example

Examples

collapse all

Suppose you have a model named myModel.

Add two parameters to the model, named myParam1 and myParam2. Set the value of myParam1 to 5, and the value of myParam2 to My text.

add_param("myModel",myParam1="5",myParam2="My text");

Check the values of the new parameters using the get_param function.

val1 = get_param("myModel","myParam1")
val2 = get_param("myModel","myParam2")
val1 =
    '5'
val2 =
    'My text'

Input Arguments

collapse all

Model to which you want to add parameters, specified as a handle or name. Format the handle as a numeric scalar, and the name as a string or character vector. The model must be an SLX or MDL file.

For information about getting handles, see Get Handles and Paths.

Data Types: double | string | character vector

Name of new parameter, specified as a string or character vector. The name cannot be the same as the name of an existing parameter of the model. Parameter names are case insensitive.

Dependencies

To use this parameter, specify a corresponding val1 argument.

Data Types: string | character vector

Initial value of parameter, specified as a string or character vector. Values are case sensitive.

Dependencies

To use this parameter, specify a corresponding param1 argument.

Version History

Introduced before R2006a