Main Content

Use Parameters to Store Instance Values with Components

This example shows how to add value types as model arguments to a System Composer™ architecture model of a wheel, mWheelArch.slx, using the Model Explorer. Then, on the System Composer architecture model mAxleArch.slx, these model arguments are exposed as instance-specific parameter values that can be changed independently across each component that references mWheelArch.

Use Model Explorer to Add MATLAB Variables as Model Arguments

Open the mWheelArch model.


Navigate to Modeling > Model Explorer or enter Ctrl+H. The Model Explorer opens. Expand the mWheelArch model and select Model Workspace. View the contents of the model workspace. The workspace contains three Simulink Parameters named Diameter, Pressure, and Wear.


To add a new MATLAB® variable to the model workspace, on the toolstrip menu, click icon.png. You can rename your variable from the default name Var and set its starting value. If you select the Argument check box, the MATLAB variable becomes a model argument. As a model argument, the variable can later be exposed as an instance-specific parameter value in an architecture model. Rename the variable to TreadDepth and set its value to 1, then select it as a model argument.


Use Model Explorer to Add Simulink Parameters as Model Arguments

In the Model Explorer, you can also add Simulink® parameters as model arguments. To add a new Simulink parameter to the model workspace, on the toolstrip menu, click simu.png. You can edit the attributes of a Simulink parameter including: Name, Value, DataType, Dimensions, Complexity, Min, Max, and Unit. These attributes contribute to the parameter definition when the parameter is specified as a model argument. Select the Argument check box to specify a parameter as a model argument. Rename the variable to PressureBar, set its value to 2000, set its units to mbar, then select it as a model argument.


Right-click the mWheel model in the Model Explorer. Save these changes to the model workspace, then close the Model Explorer.

View and Edit Parameters on Components in Architecture Model

Open the mAxleArch architecture model.


Select the LeftWheel component that references the mWheel model. The parameters appear on the Property Inspector with default values.


You can expose these parameters as model arguments and then edit the parameters as instance-specific parameters independently for each component that references the same model. Right-click the RightWheel component and select Block Parameters (Model Reference). Click the Instance parameters tab and select the Argument check box for the new parameters Pressure and TreadDepth.


Once selected, these parameters are treated as model arguments of the mAxleArch model and can be changed independently for each instance the model.

Edit the parameters for the RightWheel component so that Pressure and PressureBar are now 31 psi and 2100 mbar, respectively.


The corresponding parameter values for the LeftWheel component remain unchanged.

See Also

| | | | | | | | | |

Related Topics