Class that represents model element in analysis instance
The Instance class represents an instance of a model
element.
Related classes include:
Create an instance of an architecture.
instance = instantiate(model.Architecture,'LatencyProfile','NewInstance', ... 'Function',@calculateLatency,'Arguments','3','Strict',true, ... 'NormalizeUnits',false,'Direction','PreOrder')
Name — Name of instanceName of instance, specified as a character vector.
Example: 'NewInstance'
Data Types: char
getValue | Get value of property from element instance |
setValue | Set value of property for element instance |
hasValue | Find if element instance has property value |
isArchitecture | Find if instance is architecture instance |
isComponent | Find if instance is component instance |
isConnector | Find if instance is connector instance |
isPort | Find if instance is port instance |
This example shows an instantiation for analysis for a system with latency in its wiring. The materials used are copper, fiber, and WiFi.
Create a 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('LatencyProfile'); % Add base stereotype with properties latencybase = profile.addStereotype('LatencyBase'); latencybase.addProperty('latency','Type','double'); latencybase.addProperty('dataRate','Type','double','DefaultValue','10'); % Add connector stereotype with properties connLatency = profile.addStereotype('ConnectorLatency','Parent',... 'LatencyProfile.LatencyBase'); connLatency.addProperty('secure','Type','boolean','DefaultValue','true'); connLatency.addProperty('linkDistance','Type','double'); % Add component stereotype with properties nodeLatency = profile.addStereotype('NodeLatency','Parent',... 'LatencyProfile.LatencyBase'); nodeLatency.addProperty('resources','Type','double','DefaultValue','1'); % Add port stereotype with properties portLatency = profile.addStereotype('PortLatency','Parent',... 'LatencyProfile.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',true); % Create new model arch = model.Architecture; model.applyProfile('LatencyProfile'); % Apply profile to model % Create components, ports, and connections components = addComponent(arch,{'Sensor','Planning','Motion'}); sensorPorts = addPort(components(1).Architecture,{'MotionData','SensorData'},{'in','out'}); planningPorts = addPort(components(2).Architecture,{'SensorData','MotionCommand'},{'in','out'}); motionPorts = addPort(components(3).Architecture,{'MotionCommand','MotionData'},{'in','out'}); c_sensorData = connect(arch,components(1),components(2)); c_motionData = connect(arch,components(3),components(1)); c_motionCommand = connect(arch,components(2),components(3)); % Clean up canvas Simulink.BlockDiagram.arrangeSystem('archModel'); % Batch apply stereotypes to model elements batchApplyStereotype(arch,'Component','LatencyProfile.NodeLatency'); batchApplyStereotype(arch,'Port','LatencyProfile.PortLatency'); batchApplyStereotype(arch,'Connector','LatencyProfile.ConnectorLatency'); % Instantiate using the analysis function instance = instantiate(model.Architecture,'LatencyProfile','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
Components: [1x3 systemcomposer.analysis.ComponentInstance]
Ports: [0x0 systemcomposer.analysis.PortInstance]
Connectors: [1x3 systemcomposer.analysis.ConnectorInstance]
Name: 'NewInstance'
Inspect Component, Port, and Connector Instances
Get properties from component, port, and connector instances.
defaultResources = instance.Components(1).getValue('LatencyProfile.NodeLatency.resources')defaultResources = 1
defaultSecure = instance.Connectors(1).getValue('LatencyProfile.ConnectorLatency.secure')defaultSecure = logical
1
defaultQueueDepth = instance.Components(1).Ports(1).getValue('LatencyProfile.PortLatency.queueDepth')defaultQueueDepth = 4.2900
Clean Up
Uncomment the following code and run to clean up the artifacts created by this example:
% bdclose('archModel') % systemcomposer.profile.Profile.closeAll
Overview
This example shows how to model a typical automotive electrical system as an architectural model and run primitive analysis. The elements in the model can be broadly grouped as either source or load. Various properties of the sources and loads are set as part of the stereotype. The example uses the iterate method of the specification API to iterate through each element of the model and run analysis using the stereotype properties.
Structure of the Model
The generator charges the battery while the engine is running. The battery, along with the generator supports the electrical loads in the vehicle, like ECU, radio, and body control. The inductive loads like motors and other coils have the InRushCurrent stereotype property defined. Based on the properties set on each component, the following analyses are performed:
Total KeyOffLoad.
Number of days required for KeyOffLoad to discharge 30% of the battery.
Total CrankingInRush current.
Total Cranking current.
Ability of the battery to start the vehicle at 0°F based on the battery cold cranking amps (CCA). The discharge time is computed based on Puekert coefficient (k), which describes the relationship between the rate of discharge and the available capacity of the battery.
Load the Model and Run the Analysis
archModel = systemcomposer.openModel('scExampleAutomotiveElectricalSystemAnalysis'); % Instantiate battery sizing class used by the analysis function to store % analysis results. objcomputeBatterySizing = computeBatterySizing; % Run the analysis using the iterator. archModel.iterate('Topdown',@computeLoad,objcomputeBatterySizing); % Display analysis results. objcomputeBatterySizing.displayResults;
Total KeyOffLoad: 158.708 mA Number of days required for KeyOffLoad to discharge 30% of battery: 55.789. Total CrankingInRush current: 70 A Total Cranking current: 104 A CCA of the specifed battery is sufficient to start the car at 0 F.

Close the Model
bdclose('scExampleAutomotiveElectricalSystemAnalysis');
| 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 captured in the system model. | Use analysis to calculate overall reliability, mass roll-up, performance, or thermal characteristics of a system, or to perform a SWaP analysis. | Analyze Architecture |
| instance | An instance is an occurrence of an architecture model at a given point of time. | You can update an instance with changes to a model, but the instance will not update with changes in active variants or model references. You can use an instance, saved in an .MAT file, of a System Composer™ architecture model for analysis. | Create a Model Instance for Analysis |
| 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. You can represent specific architectures using alternate views. | Different types of architectures describe different aspects of systems:
| Compose Architecture Visually |
| model | A System Composer model is the file that contains architectural information, including components, ports, connectors, interfaces, and behaviors. | Perform operations on a model:
System Composer models are stored as | Create an Architecture Model |
| component | A component is a nontrivial, nearly-independent, and replaceable part of a system that fulfills a clear function in the context of an architecture. A component defines an architecture element, such as a function, a 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. | Components |
| 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. | There are different types of ports:
| Ports |
| 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. | Connections |
deleteInstance | instantiate | iterate | loadInstance | refresh | save | systemcomposer.analysis.ArchitectureInstance | systemcomposer.analysis.ComponentInstance | systemcomposer.analysis.ConnectorInstance | systemcomposer.analysis.PortInstance | update
You have a modified version of this example. Do you want to open this example with your edits?