Main Content


Port in analysis instance


    A PortInstance object represents an instance of a port.


    Create an instance of an architecture using the instantiate function.

    instance = instantiate(model.Architecture,'LatencyProfile','NewInstance', ...
    'Function',@calculateLatency,'Arguments','3','Strict',true, ...


    expand all

    Name of instance, specified as a character vector.

    Example: 'NewInstance'

    Data Types: char

    Component that contains port, specified as a systemcomposer.analysis.ComponentInstance object.

    Reference to port in design model, specified as a systemcomposer.arch.BasePort object.

    Qualified name of port, specified as a character vector of the form '<PathToComponent>:<PortDirection>'.

    Example: 'model/Component:In'

    Data Types: char

    Incoming connection, specified as a systemcomposer.analysis.ConnectorInstance object.

    Outgoing connection, specified as a systemcomposer.analysis.ConnectorInstance object.

    Object Functions

    getValueGet value of property from element instance
    setValueSet value of property for element instance
    hasValueFind if element instance has property value
    isArchitectureFind if instance is architecture instance
    isComponentFind if instance is component instance
    isConnectorFind if instance is connector instance
    isPortFind if instance is port instance


    collapse all

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

    Add a connector stereotype with properties.

    connLatency = profile.addStereotype("ConnectorLatency",...

    Add a component stereotype with properties.

    nodeLatency = profile.addStereotype("NodeLatency",...

    Add a port stereotype with properties.

    portLatency = profile.addStereotype("PortLatency",...

    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");
    ans = 
      Model with properties:
                       Name: 'archModel'
               Architecture: [1x1 systemcomposer.arch.Architecture]
             SimulinkHandle: 152.0010
                      Views: [0x0 systemcomposer.view.View]
                   Profiles: [0x0 systemcomposer.profile.Profile]
        InterfaceDictionary: [1x1 systemcomposer.interface.Dictionary]
    arch = model.Architecture;

    Apply profile to model.


    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,...
    componentMotion = addComponent(arch,"Motion");
    motionPorts = addPort(componentMotion.Architecture,...
    c_sensorData = connect(arch,componentSensor,componentPlanning);
    c_motionData = connect(arch,componentMotion,componentSensor);
    c_motionCommand = connect(arch,componentPlanning,componentMotion);

    Clean up the canvas.


    Batch apply stereotypes to model elements.


    Instantiate using the analysis function.

    instance = instantiate(model.Architecture,"LatencyProfileC","NewInstance",...
        Function=@calculateLatency,Arguments="3", ...
    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]
                     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("")
    defaultSecure = logical
    defaultQueueDepth = instance.Components(1).Ports(1).getValue("LatencyProfileC.PortLatency.queueDepth")
    defaultQueueDepth = 4.2900


    Model a typical automotive electrical system as an architectural model and run a primitive analysis. The elements in the model can be broadly grouped as either a source or a load. Various properties of the sources and loads are set as part of the stereotype. This 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 Model

    The generator charges the battery while the engine is running. The battery and the generator support 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 Model and Run Analysis

    archModel = systemcomposer.loadModel('scExampleAutomotiveElectricalSystemAnalysis');

    Instantiate battery sizing class used by the analysis function to store analysis results.

    objcomputeBatterySizing = computeBatterySizing;

    Run the analysis using the iterator.


    Display analysis results.

    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 specified battery is sufficient to start the car at 0 F.
    ans = 
      computeBatterySizing with properties:
        totalCrankingInrushCurrent: 70
              totalCrankingCurrent: 104
            totalAccesoriesCurrent: 71.6667
                   totalKeyOffLoad: 158.7080
                        batteryCCA: 500
                   batteryCapacity: 850
                puekertcoefficient: 1.2000


    Close Model


    More About

    expand all

    Version History

    Introduced in R2019a