instantiate
Create analysis instance from specification
Syntax
Description
creates an instance instance
= instantiate(arch
,properties
,name
)instance
named name
of a model
architecture arch
with properties properties
for
analysis. Get the Architecture
property of the systemcomposer.arch.Model
object model
using
model.Architecture
in the MATLAB® Command Window.
Note
This function is part of the instance programmatic interfaces that you can use to analyze
the model iteratively, element-by-element. The instance
refers to the
element instance on which the iteration is being performed.
creates an instance of a model architecture for analysis with additional arguments.instance
= instantiate(___,Name=Value
)
Examples
Instantiate All Properties of Stereotypes in Profile
Instantiate all properties of stereotypes in a profile that will be applied to specific elements during instantiation.
Create a profile for latency characteristics and save it.
profile = systemcomposer.profile.Profile.createProfile("LatencyProfile"); latencybase = profile.addStereotype("LatencyBase"); latencybase.addProperty("latency",Type="double"); latencybase.addProperty("dataRate",Type="double",DefaultValue="10"); connLatency = profile.addStereotype("ConnectorLatency",... Parent="LatencyProfile.LatencyBase"); connLatency.addProperty("secure",Type="boolean"); connLatency.addProperty("linkDistance",Type="double"); nodeLatency = profile.addStereotype("NodeLatency",... Parent="LatencyProfile.LatencyBase"); nodeLatency.addProperty("resources",Type="double",DefaultValue="1"); portLatency = profile.addStereotype("PortLatency",... Parent="LatencyProfile.LatencyBase"); portLatency.addProperty("queueDepth",Type="double"); portLatency.addProperty("dummy",Type="int32"); profile.save
Create a new model and apply the profile to the model.
model = systemcomposer.createModel("archModel"); model.applyProfile("LatencyProfile");
Specify type of elements each stereotype can be applied on.
NodeLatency = struct("elementKinds",["Component"]); ConnectorLatency = struct("elementKinds",["Connector"]); LatencyBase = struct("elementKinds",["Connector","Port","Component"]); PortLatency = struct("elementKinds",["Port"]);
Create the analysis structure.
LatencyAnalysis = struct("NodeLatency",NodeLatency, ... "ConnectorLatency",ConnectorLatency, ... "PortLatency",PortLatency, ... "LatencyBase",LatencyBase);
Create the properties structure.
properties = struct("LatencyProfile",LatencyAnalysis);
Instantiate all properties of stereotypes in the profile.
instance = instantiate(model.Architecture,properties,"NewInstance")
Instantiate Specific Properties of Stereotypes in Profile
Instantiate specific properties of stereotypes in a profile that will be applied to specific elements during instantiation.
Create a profile for latency characteristics and save it.
profile = systemcomposer.profile.Profile.createProfile("LatencyProfile"); latencybase = profile.addStereotype("LatencyBase"); latencybase.addProperty("latency",Type="double"); latencybase.addProperty("dataRate",Type="double",DefaultValue="10"); connLatency = profile.addStereotype("ConnectorLatency",... Parent="LatencyProfile.LatencyBase"); connLatency.addProperty("secure",Type="boolean"); connLatency.addProperty("linkDistance",Type="double"); nodeLatency = profile.addStereotype("NodeLatency",... Parent="LatencyProfile.LatencyBase"); nodeLatency.addProperty("resources",Type="double",DefaultValue="1"); portLatency = profile.addStereotype("PortLatency",... Parent="LatencyProfile.LatencyBase"); portLatency.addProperty("queueDepth",Type="double"); portLatency.addProperty("dummy",Type="int32"); profile.save
Create a new model and apply the profile to the model.
model = systemcomposer.createModel("archModel"); model.applyProfile("LatencyProfile");
Specify some properties of the stereotypes in the profile.
NodeLatency = struct("elementKinds",["Component"], ... "properties",struct("resources",true)); ConnectorLatency = struct("elementKinds",["Connector"], ... "properties",struct("secure",true,"linkDistance",true)); LatencyBase = struct("elementKinds",[], ... "properties",struct("dataRate",true,"latency",false)); PortLatency = struct('elementKinds',["Port"], ... "properties",struct("queueDepth",true)); LatencyAnalysis = struct("NodeLatency",NodeLatency, ... "ConnectorLatency",ConnectorLatency, ... "PortLatency",PortLatency, ... "LatencyBase",LatencyBase);
Create the properties structure.
properties = struct("LatencyProfile",LatencyAnalysis);
Instantiate some properties of stereotypes in the profile.
instance = instantiate(model.Architecture,properties,"NewInstance")
Instantiate All Stereotypes in Profile
Instantiate all stereotypes already in a profile that will be applied to elements during instantiation.
Create a profile for latency characteristics and save it.
profile = systemcomposer.profile.Profile.createProfile("LatencyProfile"); latencybase = profile.addStereotype("LatencyBase"); latencybase.addProperty("latency",Type="double"); latencybase.addProperty("dataRate",Type="double",DefaultValue="10"); connLatency = profile.addStereotype("ConnectorLatency",... Parent="LatencyProfile.LatencyBase"); connLatency.addProperty("secure",Type="boolean"); connLatency.addProperty("linkDistance",Type="double"); nodeLatency = profile.addStereotype("NodeLatency",... Parent="LatencyProfile.LatencyBase"); nodeLatency.addProperty("resources",Type="double",DefaultValue="1"); portLatency = profile.addStereotype("PortLatency",... Parent="LatencyProfile.LatencyBase"); portLatency.addProperty("queueDepth",Type="double"); portLatency.addProperty("dummy",Type="int32"); profile.save
Create a new model and apply the profile to the model.
model = systemcomposer.createModel("archModel"); model.applyProfile("LatencyProfile");
Instantiate all stereotypes in a profile.
instance = instantiate(model.Architecture,"LatencyProfile","NewInstance")
Analyze Latency Characteristics
Create an instantiation for analysis for a system with latency in its wiring. The materials used are copper, fiber, and WiFi.
Create Latency Profile with Stereotypes and Properties
Create a System Composer profile with a base, connector, component, and port stereotype. Add properties with default values to each stereotype as needed for analysis.
profile = systemcomposer.profile.Profile.createProfile("LatencyProfileC");
Add a base stereotype with properties.
latencybase = profile.addStereotype("LatencyBase"); latencybase.addProperty("latency",Type="double"); latencybase.addProperty("dataRate",Type="double",DefaultValue="10");
Add a connector stereotype with properties.
connLatency = profile.addStereotype("ConnectorLatency",... Parent="LatencyProfileC.LatencyBase"); connLatency.addProperty("secure",Type="boolean",DefaultValue="true"); connLatency.addProperty("linkDistance",Type="double");
Add a component stereotype with properties.
nodeLatency = profile.addStereotype("NodeLatency",... Parent="LatencyProfileC.LatencyBase"); nodeLatency.addProperty("resources",Type="double",DefaultValue="1");
Add a port stereotype with properties.
portLatency = profile.addStereotype("PortLatency",... Parent="LatencyProfileC.LatencyBase"); portLatency.addProperty("queueDepth",Type="double",DefaultValue="4.29"); portLatency.addProperty("dummy",Type="int32");
Instantiate Using Analysis Function
Create a new model and apply the profile. Create components, ports, and connections in the model. Apply stereotypes to the model elements. Finally, instantiate using the analysis function.
model = systemcomposer.createModel("archModel"); systemcomposer.openModel("archModel")
ans = Model with properties: Name: 'archModel' SimulinkHandle: 152.0012 Architecture: [1x1 systemcomposer.arch.Architecture] Profiles: [0x0 systemcomposer.profile.Profile] InterfaceDictionary: [1x1 systemcomposer.interface.Dictionary] Views: [0x0 systemcomposer.view.View] Interactions: [0x0 systemcomposer.interaction.Interaction]
arch = model.Architecture;
Apply profile to model.
model.applyProfile("LatencyProfileC");
Create components, ports, and connections.
componentSensor = addComponent(arch,"Sensor"); sensorPorts = addPort(componentSensor.Architecture,{'MotionData','SensorPower'},{'in','out'}); componentPlanning = addComponent(arch,"Planning"); planningPorts = addPort(componentPlanning.Architecture,... {'Command','SensorPower','MotionCommand'},... {'in','in','out'}); componentMotion = addComponent(arch,"Motion"); motionPorts = addPort(componentMotion.Architecture,... {'MotionCommand','MotionData'},{'in','out'}); c_sensorData = connect(arch,componentSensor,componentPlanning); c_motionData = connect(arch,componentMotion,componentSensor); c_motionCommand = connect(arch,componentPlanning,componentMotion);
Clean up the canvas.
Simulink.BlockDiagram.arrangeSystem("archModel");
Batch apply stereotypes to model elements.
batchApplyStereotype(arch,"Component","LatencyProfileC.NodeLatency"); batchApplyStereotype(arch,"Port","LatencyProfileC.PortLatency"); batchApplyStereotype(arch,"Connector","LatencyProfileC.ConnectorLatency");
Instantiate using the analysis function.
instance = instantiate(model.Architecture,"LatencyProfileC","NewInstance",... Function=@calculateLatency,Arguments="3", ... Strict=true,NormalizeUnits=false,Direction="PreOrder")
instance = ArchitectureInstance with properties: Specification: [1x1 systemcomposer.arch.Architecture] IsStrict: 1 NormalizeUnits: 0 AnalysisFunction: @calculateLatency AnalysisDirection: PreOrder AnalysisArguments: '3' ImmediateUpdate: 0 listenerFnc: [] Components: [1x3 systemcomposer.analysis.ComponentInstance] Ports: [0x0 systemcomposer.analysis.PortInstance] Connectors: [1x3 systemcomposer.analysis.ConnectorInstance] Parameters: [0x0 systemcomposer.analysis.InstanceParameter] Name: 'NewInstance'
Inspect Component, Port, and Connector Instances
Get properties from component, port, and connector instances.
defaultResources = instance.Components(1).getValue("LatencyProfileC.NodeLatency.resources")
defaultResources = 1
defaultSecure = instance.Connectors(1).getValue("LatencyProfileC.ConnectorLatency.secure")
defaultSecure = logical
1
defaultQueueDepth = instance.Components(1).Ports(1).getValue("LatencyProfileC.PortLatency.queueDepth")
defaultQueueDepth = 4.2900
Input Arguments
arch
— Architecture
architecture object
Architecture, specified as a systemcomposer.arch.Architecture
object.
properties
— Stereotype properties
structure
Stereotype properties, specified as a structure containing profile, stereotype, and
property information. Use properties
to specify which stereotypes
and properties need to be instantiated.
Data Types: struct
name
— Name of instance
character vector | string
Name of instance generated from the model, specified as a character vector or string.
Example: "NewInstance"
Data Types: char
| string
profile
— Profile name
character vector | string
Profile name, specified as a character vector or string.
Example: 'LatencyProfile'
Data Types: char
| string
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose
Name
in quotes.
Example: instantiate(model.Architecture,"LatencyProfile","NewInstance",Function=@calculateLatency,Arguments="3",Strict=true,NormalizeUnits=false,Direction="PreOrder")
NormalizeUnits
— Whether to normalize value based on units
0
(false
) (default) | 1
(true
)
Whether to normalize value based on units, if any, specified in property
definition upon instantiation, specified as 1
(true
) or 0
(false
).
Example: instantiate(model.Architecture,'LatencyProfile','NewInstance','NormalizeUnits',true)
Data Types: logical
Function
— Analysis function
function handle
Analysis function, specified as the MATLAB function handle to be executed when analysis is run.
Arguments
— Analysis arguments
cell array of character vectors | array of strings | character vector | string
Analysis arguments, specified as a character vector, string, array of strings, or a cell array of character vectors of optional arguments to the analysis function.
Data Types: char
| string
Direction
— Iteration type
"PreOrder"
| "PostOrder"
| "TopDown"
| "BottomUp"
Iteration type, specified as "PreOrder"
,
"PostOrder"
, "TopDown"
, or
"BottomUp"
.
Pre-order
— Start from the top level, move to a child component, and process the subcomponents of that component recursively before moving to a sibling component.Top-Down
— Like pre-order, but process all sibling components before moving to their subcomponents.Post-order
— Start from components with no subcomponents, process each sibling, and then move to parent.Bottom-up
— Like post-order, but process all subcomponents at the same depth before moving to their parents.
Data Types: char
| string
Strict
— Condition for instances getting properties
0
(false
) (default) | 1
(true
)
Condition for instances getting properties only if the specification of the
instance has the stereotype applied, specified as 1
(true
) or 0
(false
).
Data Types: logical
Output Arguments
instance
— Architecture instance
architecture instance object
Architecture instance, returned as a
systemcomposer.analysis.ArchitectureInstance
object.
More About
Definitions
Term | Definition | Application | More Information |
---|---|---|---|
architecture | A System Composer™ architecture represents a system of components and how they interface with each other structurally and behaviorally. |
Different types of architectures describe different aspects of systems. You can use views to visualize a subset of components in an architecture. You can define parameters on the architecture level using the Parameter Editor. | |
root | A root is at the top of an architecture hierarchy. A root architecture has a boundary defined by its architecture ports that surround the system of interest. | The root architecture has a system boundary surrounding your architecture model. You can add architecture ports that define interfaces across the boundary. | |
model | A System Composer model is the file that contains architectural information, such as components, ports, connectors, interfaces, and behaviors. |
Perform operations on a model:
A System Composer model is stored as an SLX file. | Create Architecture Model with Interfaces and Requirement Links |
component | A component is a replaceable part of a system that fulfills a clear function in the context of an architecture. A component defines an architectural element, such as a function, another system, hardware, software, or other conceptual entity. A component can also be a subsystem or subfunction. | Represented as a block, a component is a part of an architecture model that can be separated into reusable artifacts. Transfer information between components with:
| |
port | A port is a node on a component or architecture that represents a point of interaction with its environment. A port permits the flow of information to and from other components or systems. |
| |
connector | Connectors are lines that provide connections between ports. Connectors describe how information flows between components or architectures. | A connector allows two components to interact without defining the nature of the interaction. Set an interface on a port to define how the components interact. |
Term | Definition | Application | More Information |
---|---|---|---|
stereotype | Stereotypes provide a mechanism to extend the core language elements and add domain-specific metadata. | Apply stereotypes to core element types. An element can have multiple stereotypes. Stereotypes allow you to style different elements. Stereotypes provide elements with a common set of properties, such as mass, cost, and power. | |
property | A property is a field in a stereotype. You can specify property values for each element to which the stereotype is applied. | Use properties to store quantitative characteristics, such as weight or speed, that are associated with a model element. Properties can also be descriptive or represent a status. You can view and edit the properties of each element in the architecture model using the Property Inspector. For more information, see Use Property Inspector in System Composer. | |
profile | A profile is a package of stereotypes. | You can use profiles to create a domain of specialized element types. Author profiles and apply profiles to a model using the Profile Editor. You can store stereotypes for a project in one or several profiles. When you save profiles, they are stored in XML files. |
Term | Definition | Application | More Information |
---|---|---|---|
analysis | Analysis is a method for quantitatively evaluating an architecture for certain characteristics. Static analysis analyzes the structure of the system. Static analysis uses an analysis function and parametric values of properties and parameters captured in the system model. | Use analyses to calculate overall reliability, mass roll-up, performance, or thermal characteristics of a system, or to perform a size, weight, and power (SWaP) analysis to increase efficiency. | |
analysis function | An analysis function is a MATLAB function that computes values necessary to evaluate the architecture using the properties of each element in the model instance and instance-specific parameters on the component and architecture level. | Use an analysis function to calculate the result of an analysis. | |
instance model | An instance model is a collection of instances. | You can update an instance model with changes to a model, but
the instance model will not update with changes in active variants or model references. You can
use an instance model, saved in a | Run Analysis Function |
instance | An instance is an occurrence of an architecture model element at a given point in time. | An instance freezes the active variant or model reference of the component in the instance model. | Create a Model Instance for Analysis |
Version History
Introduced in R2019a
See Also
Tools
Functions
iterate
|lookup
|save
|update
|refresh
|systemcomposer.analysis.loadInstance
|systemcomposer.analysis.deleteInstance
|getValue
|setValue
|hasValue
|getParameter
|getEvaluatedParameterValue
|getParameterNames
|getParameterValue
|setParameterValue
|isArchitecture
|isComponent
|isConnector
|isPort
|getQualifiedName
Objects
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)