| Using Simulink |
 |
Using Model Arguments
Model arguments let you create references to the same model that behave differently. For example, suppose you want each reference to a counter model to be able to specify initial and increment values for the counter where the specified values can differ from reference to reference. Using model arguments to parameterize references to the counter model allows you to do this.
| Note
Run the mdlref_paramargs demo to see parameterized model references in action.
|
Using model arguments requires that you
- Declare model workspace variables that determine the model's behavior as model arguments
- Assign values to the model arguments in each reference to the parameterized model
The following sections explain how to perform these tasks.
Declaring Model Arguments
To declare some or all of a model's model workspace variables as model arguments:
- Open the referenced model.
- Open the Model Explorer.
- Select the model's workspace in the Model Explorer.

- If you have not already done so, use the Model Explorer to create MATLAB variables in the model's workspace that determine the model's behavior.

- Enter the names of the workspace variables that you want to declare as model arguments as a comma-separated list in the Model arguments field in the model workspace's dialog box.

- Click the Apply button on the dialog box to confirm the entered names.
Note
If a model does not declare a variable in its workspace as a model argument, the variable has the same value in every reference to the model and cannot be tuned from a parent model. For example, suppose that a model defines a variable k in its workspace but does not declare it as a model argument. Further, suppose that the model assigns a value of 5 to k in its workspace. Then the value of k will be 5 in every reference to the model in other models.
|
Assigning Values to Model Arguments
If a model declares model arguments, you must assign values to the model arguments in each reference to the model, i.e., in each Model block that references the model.
To assign values to a model's model arguments in a Model block that references the model:
- Open the Model block's parameter dialog box.

- Enter a comma-delimited list of values for the parameter arguments in the Model argument values field in the same order in which the arguments appear in the Model arguments field.

- You can enter the values as literal values, variable names, MATLAB expressions, and Simulink parameter objects. The value for a particular argument must have the same dimensions and data and numeric type as the model workspace variable that defines the argument.
| Parameterizing Model References | | Model Block Sample Times |  |
© 1994-2005 The MathWorks, Inc.