Main Content

linkToModel

Link component to model

Description

modelHandle = linkToModel(component,modelName) links from the component to a model or subsystem.

example

modelHandle = linkToModel(component,modelFileName) links from the component to a model or subsystem defined by its full file name with an SLX or SLXP extension.

Examples

collapse all

Save the component named robotComp in the architecture model Robot.slx and reference it from another component named electricComp so that the component electricComp uses the architecture of the component robotComp.

Create a model archModel.slx.

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")

Save robotComp in the Robot.slx model so the component references the model.

saveAsModel(comp(2),"Robot");

Link the electricComp component to the same model Robot.slx so it uses the architecture of the original robotComp component and references the architecture model Robot.slx.

linkToModel(comp(1),"Robot");

Clean up the model.

Simulink.BlockDiagram.arrangeSystem("archModel"); 

Input Arguments

collapse all

Component with no sub-components, specified as a systemcomposer.arch.Component object.

Model or subsystem name for an existing model or subsystem that defines the architecture or behavior of the component, specified as a character vector or string. Models or subsystems of the same name prioritize protected models with the SLXP extension.

Example: "Robot"

Data Types: char | string

Model or subsystem file name for an existing model or subsystem that defines the architecture or behavior of the component, specified as a character vector or string.

Example: "Model.slx"

Example: "ProtectedModel.slxp"

Data Types: char | string

Output Arguments

collapse all

Handle to linked model or subsystem, returned as a numeric value.

Data Types: double

More About

collapse all

Version History

Introduced in R2019a