Main Content

createSimulinkBehavior

Create Simulink behavior and link to component

Description

createSimulinkBehavior(component,modelName) creates a new Simulink® model, modelName, with the same interfaces as the component component and links the component to the new model. The component must have no children.

Note

Components with physical ports cannot be saved as architecture models, model references, software architectures, or Stateflow® chart behaviors. Components with physical ports can only be saved as subsystem references or as subsystem component behaviors.

If no functions are present in software architectures, this syntax creates a rate-based behavior. If functions are present, the syntax creates an export-function behavior.

example

createSimulinkBehavior(component,modelName,"Type",type) creates a new Simulink model or subsystem behavior, modelName, with the same interfaces as the component component and links the component to the new model. For more information, see Create Referenced Simulink Behavior Model.

Use this syntax to convert a subsystem component to a subsystem reference.

example

createSimulinkBehavior(component,"Type",type) creates a subsystem component behavior that is part of the parent model. The connections, interfaces, requirement links, and stereotypes of the component are preserved. The component must have no subcomponents and must not already be linked to a model. For more information, see Create Simulink Behavior Using Subsystem Component.

example

createSimulinkBehavior(component,modelName,"BehaviorType",behavior) creates a new Simulink rate-based or export-function behavior, modelName, and links the software component to the new model. You can create rate-based or export-function behaviors for software architectures.

example

Examples

collapse all

Create a Simulink model behavior for the component robotComp in Robot.slx and link the model file to the component.

Create a model archModel.

model = systemcomposer.createModel("archModel");
systemcomposer.openModel("archModel");
arch = get(model,"Architecture");

Add two components to the model electricComp and robotComp. Rearrange the model.

names = ["electricComp","robotComp"];
comp = addComponent(arch,names);
Simulink.BlockDiagram.arrangeSystem("archModel")

Create a Simulink behavior model for the robotComp component so the component references the Simulink model Robot.slx.

createSimulinkBehavior(comp(2),"Robot")

Create a Simulink subsystem behavior for the component robotComp in Robot.slx and link the subsystem file to the component.

Create a model archModel.

model = systemcomposer.createModel("archModel");
systemcomposer.openModel("archModel");
arch = get(model,"Architecture");

Add two components to the model electricComp and robotComp. Rearrange the model.

names = ["electricComp","robotComp"];
comp = addComponent(arch,names);
Simulink.BlockDiagram.arrangeSystem("archModel")

Create a Simulink subsystem reference behavior for the robotComp component so the component references the Simulink subsystem Robot.slx.

createSimulinkBehavior(comp(2),"Robot",Type="SubsystemReference")

Create a Simulink subsystem behavior for the component robotComp in Robot.slx and link the subsystem file to the component.

Create a model archModel.

model = systemcomposer.createModel("archModel");
systemcomposer.openModel("archModel");
arch = get(model,"Architecture");

Add two components to the model electricComp and robotComp. Rearrange the model.

names = ["electricComp","robotComp"];
comp = addComponent(arch,names);
Simulink.BlockDiagram.arrangeSystem("archModel")

Create a Simulink subsystem component behavior for the robotComp component that is part of the parent model.

createSimulinkBehavior(comp(2),Type="Subsystem")

Convert the subsystem component to a subsystem reference component behavior so the component references the Simulink subsystem Robot.slx.

createSimulinkBehavior(comp(2),"Robot",Type="SubsystemReference")

Create a Simulink model with export-function behavior myBehaviorModel.slx for the software component named C1 and link the model to the component.

Create a software architecture model named mySoftwareModel.

model=systemcomposer.createModel("mySoftwareModel","SoftwareArchitecture");
systemcomposer.openModel("mySoftwareModel");
arch = get(model,"Architecture");

Add a component C1 to the model.

comp = addComponent(arch,"C1");

Create a Simulink model with an export-function behavior named myBehaviorModel.slx that is referenced by the component C1.

createSimulinkBehavior(comp,"myBehaviorModel",BehaviorType="ExportFunction")

Input Arguments

collapse all

System or software architecture component with no children, specified as a systemcomposer.arch.Component object. This component can also be specified as a subsystem component to be converted to a subsystem reference.

Name of model, specified as a character vector or string.

Example: "exMobileRobot"

Data Types: char | string

Component behavior, specified as one of these values:

  • "RateBased" to create a rate-based component behavior

  • "ExportFunction" to create an export-function component behavior

Data Types: char | string

Component behavior, specified as one of these values:

  • "ModelReference" to create a Simulink model reference component behavior

  • "SubsystemReference" to create a Simulink subsystem reference component behavior

  • "Subsystem" to create a Simulink subsystem component behavior

Data Types: char | string

More About

collapse all

Version History

Introduced in R2019a