Main Content

Author Parameters in System Composer Using Parameter Editor

This example shows how to add and modify parameters for a System Composer™ architecture model of a propeller by using a top-down authoring workflow available in the Parameter Editor. System Composer parameters synchronize with Simulink® for seamless simulation and code generation.This example also shows how to export and import a System Composer architecture model of a propeller with set parameters.

1. Create an architecture model named Propeller. Add a component to the model and name it Hub.

propellerarch.png

2. Click the Hub component, then open the Property Inspector. Pin the Property Inspector for easy access. To open the Parameter Editor, in the Property Inspector, next to Parameters, from the Select list, select Open Editor.

3. In the Parameters tab, click Add parameter. Define a parameter named bladePitch with default value 45 and unit degrees.

2022-08-22_13-45-54.png

4. Click the Propeller root architecture. Open the Parameter Editor. Add a parameter named advanceSpeed. Set Value as 500 and Unit as mph.

5. Define a parameter named spinningRate. Set Value as 3 and Unit as Hz.

6. To open the Parameter Promotion: One-To-One section, click Promote parameter. Under the component Hub, select the bladePitch parameter. To promote the parameter, click Promote.

Parameter promotion provides easy access to parameter values and preserves distinct parameter values inside the model during simulation or code generation. Parameter promotion also removes unnecessary duplication of parameters defined on lower levels of an architectural hierarchy.

2022-08-22_13-47-57.png

7. From the source component Hub, change the default value of the promoted parameter bladePitch to 72. The new value of the bladePitch parameter now appears for the architecture Propeller.

changevalue.png

Export Architecture With Parameters

In addition to components, ports, connections, interfaces, and requirement links, you can export the Propeller architecture with parameters to MATLAB® tables.

exportedSet = systemcomposer.exportModel("Propeller");

The output of the function is a structure that contains the components table, ports table, connections table, port interfaces table, requirement links table, and parameters table.

Exported set with the parameters table.

Import Architecture With Parameters

The parameters table in the exportedSet structure includes parameters information. You can import those parameters into a new model. Specify a name for the imported architecture model.

modelName = "ImportedPropellerArchitecture";

You can import an architecture into System Composer when components, ports, connections, port interfaces, requirement links, and parameters information is defined in or converted into MATLAB tables.

model = systemcomposer.importModel(modelName,exportedSet.components,...
    exportedSet.ports,exportedSet.connections,exportedSet.portInterfaces,...
    exportedSet.requirementLinks,exportedSet.parameters);

Auto-arrange blocks in the generated model.

Simulink.BlockDiagram.arrangeSystem(modelName)

Parameters and promoted parameter for the imported propeller architecture model.

See Also

Tools

Objects

Functions

Related Topics