Main Content

addParameter

Add parameter to architecture

    Description

    example

    param = addParameter(arch,paramName) adds a parameter, param, with the name paramName to the architecture arch.

    To delete a parameter, use the destroy function.

    example

    param = addParameter(arch,Name,Value) promotes a parameter from a component specified by a path to the parent architecture arch.

    Examples

    collapse all

    This example shows a wheel axle architecture model with instance-specific parameters exposed in System Composer™. These parameters are defined as model arguments on the Simulink® reference model used as a model behavior linked to two System Composer components. You can change the values of these parameters independently on each reference component.

    To add parameters to the architecture model or components, use the Parameter Editor. To remove these parameters, delete them from the Parameter Editor.

    Open the architecture model of the wheel axle mAxleArch to interact with the parameters on the reference components using the Property Inspector.

    model = systemcomposer.openModel("mAxleArch");

    Look up the Component objects for the RightWheel and LeftWheel components.

    rightWheelComp = lookup(model,Path="mAxleArch/RightWheel");
    leftWheelComp = lookup(model,Path="mAxleArch/LeftWheel");

    Get the parameter names for the RightWheel component. Since the LeftWheel component is linked to the same reference model mWheel, the parameters are the same on the LeftWheel component.

    paramNames = rightWheelComp.getParameterNames
    paramNames = 1×3 string
        "Diameter"    "Pressure"    "Wear"
    
    

    Get the Pressure parameter on the RightWheel component architecture.

    paramPressure = rightWheelComp.Architecture.getParameter(paramNames(2));

    Display the value type for the Pressure parameter.

    paramPressure.Type
    ans = 
      ValueType with properties:
    
               Name: 'Pressure'
           DataType: 'double'
         Dimensions: '[1  1]'
              Units: 'psi'
         Complexity: 'real'
            Minimum: ''
            Maximum: ''
        Description: ''
              Owner: [1×1 systemcomposer.arch.Architecture]
              Model: [1×1 systemcomposer.arch.Model]
               UUID: '47c2446a-f6b0-4710-9a73-7ed25d1671c4'
        ExternalUID: ''
    
    

    Get the RightWheel component parameter values.

    for i = 1:length(paramNames)
        paramName = paramNames(i)
        [paramValue,paramUnits,isDefault] = rightWheelComp.getParameterValue(paramNames(i))
    end
    paramName = 
    "Diameter"
    
    paramValue = 
    '16'
    
    paramUnits = 
    'in'
    
    isDefault = logical
       1
    
    
    paramName = 
    "Pressure"
    
    paramValue = 
    '31'
    
    paramUnits = 
    'psi'
    
    isDefault = logical
       0
    
    
    paramName = 
    "Wear"
    
    paramValue = 
    '0.25'
    
    paramUnits = 
    'in'
    
    isDefault = logical
       1
    
    

    Get the LeftWheel component parameter values.

    for i = 1:length(paramNames)
        paramName = paramNames(i)
        [paramValue,paramUnits,isDefault] = leftWheelComp.getParameterValue(paramNames(i))
    end
    paramName = 
    "Diameter"
    
    paramValue = 
    '16'
    
    paramUnits = 
    'in'
    
    isDefault = logical
       1
    
    
    paramName = 
    "Pressure"
    
    paramValue = 
    '32'
    
    paramUnits = 
    'psi'
    
    isDefault = logical
       1
    
    
    paramName = 
    "Wear"
    
    paramValue = 
    '0.25'
    
    paramUnits = 
    'in'
    
    isDefault = logical
       1
    
    

    First, check the evaluated RightWheel parameters.

    for i = 1:length(paramNames)
        paramName = paramNames(i)
        [paramValue,paramUnits] = rightWheelComp.getEvaluatedParameterValue(paramNames(i))
    end
    paramName = 
    "Diameter"
    
    paramValue = 16
    
    paramUnits = 
    'in'
    
    paramName = 
    "Pressure"
    
    paramValue = 31
    
    paramUnits = 
    'psi'
    
    paramName = 
    "Wear"
    
    paramValue = 0.2500
    
    paramUnits = 
    'in'
    

    Check the evaluated LeftWheel parameters.

    for i = 1:length(paramNames)
        paramName = paramNames(i)
        [paramValue,paramUnits] = leftWheelComp.getEvaluatedParameterValue(paramNames(i))
    end
    paramName = 
    "Diameter"
    
    paramValue = 16
    
    paramUnits = 
    'in'
    
    paramName = 
    "Pressure"
    
    paramValue = 32
    
    paramUnits = 
    'psi'
    
    paramName = 
    "Wear"
    
    paramValue = 0.2500
    
    paramUnits = 
    'in'
    

    Set the parameter value and unit for the PSI parameter on the LeftWheel component.

    First, check the current values for the pressure on LeftWheel.

    [paramValue,paramUnits,isDefault] = leftWheelComp.getParameterValue("Pressure")
    paramValue = 
    '32'
    
    paramUnits = 
    'psi'
    
    isDefault = logical
       1
    
    

    Update the values for the pressure on LeftWheel.

    leftWheelComp.setParameterValue("Pressure","34")
    [paramValue,paramUnits,isDefault] = leftWheelComp.getParameterValue("Pressure")
    paramValue = 
    '34'
    
    paramUnits = 
    'psi'
    
    isDefault = logical
       0
    
    

    Revert the Pressure parameter on LeftWheel to its default value.

    leftWheelComp.resetParameterToDefault("Pressure")

    Check the reverted values for the pressure on LeftWheel.

    [paramValue,paramUnits,isDefault] = leftWheelComp.getParameterValue("Pressure")
    paramValue = 
    '32'
    
    paramUnits = 
    'psi'
    
    isDefault = logical
       1
    
    

    Promote the Pressure parameter on the LeftWheel component.

    addParameter(model.Architecture,Path="mAxleArch/LeftWheel",Parameters="Pressure");

    Get the promoted Pressure parameter from the root architecture of the mAxleArch model.

    pressureParam = model.Architecture.getParameter("LeftWheel.Pressure");

    Adjust the value of the promoted Pressure parameter.

    pressureParam.Value = "30";
    pressureParam
    pressureParam = 
      Parameter with properties:
    
          Name: "LeftWheel.Pressure"
         Value: '30'
          Type: [1×1 systemcomposer.ValueType]
        Parent: [1×1 systemcomposer.arch.Architecture]
          Unit: 'psi'
    
    

    Get the source parameter from which the Pressure parameter is promoted.

    sourceParam = getParameterPromotedFrom(pressureParam)
    sourceParam = 
      Parameter with properties:
    
          Name: "Pressure"
         Value: '30'
          Type: [1×1 systemcomposer.ValueType]
        Parent: [1×1 systemcomposer.arch.Component]
          Unit: 'psi'
    
    

    Reset the value of the promoted Pressure parameter to the default value in the source parameter.

    resetToDefault(pressureParam);
    pressureParam
    pressureParam = 
      Parameter with properties:
    
          Name: "LeftWheel.Pressure"
         Value: '32'
          Type: [1×1 systemcomposer.ValueType]
        Parent: [1×1 systemcomposer.arch.Architecture]
          Unit: 'psi'
    
    

    Delete the promoted parameter.

    destroy(pressureParam)

    Add a new Muffler component to the mAxleArch architecture model.

    topModel = systemcomposer.loadModel("mAxleArch");
    mufflerComp = addComponent(topModel.Architecture,"Muffler");

    Add the parameter noiseReduction to the Muffler component.

    noiseReduce = addParameter(mufflerComp.Architecture,"noiseReduction");

    Set the default Unit value for the NoiseReduction parameter.

    valueTypeNoise = noiseReduce.Type;
    valueTypeNoise.Units = "dB";

    Set the Value property for the noiseReduction parameter.

    noiseReduce.Value = "30";

    View the properties of the noiseReduction parameter.

    noiseReduce
    noiseReduce = 
      Parameter with properties:
    
          Name: "noiseReduction"
         Value: '30'
          Type: [1×1 systemcomposer.ValueType]
        Parent: [1×1 systemcomposer.arch.Architecture]
          Unit: 'dB'
    
    

    Rearrange the mAxleArch architecture model to view all components.

    Simulink.BlockDiagram.arrangeSystem("mAxleArch");

    Delete the Muffler component.

    destroy(mufflerComp)

    Save the updated models.

    model = systemcomposer.loadModel("mWheelArch");
    save(model)
    save(topModel)

    Input Arguments

    collapse all

    Architecture, specified as a systemcomposer.arch.Architecture object.

    Parameter name, specified as a character vector or string.

    Example: "GainArg"

    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: addParameter(arch,Path="Propeller/Hub",Parameters="all")

    Path to component with parameter, specified as a character vector or string.

    Example: addParameter(arch,Path="Propeller/Hub")

    Data Types: char | string

    Parameters to promote, specified as "all" or an array of strings.

    Data Types: char | string

    Output Arguments

    collapse all

    Parameter, returned as a systemcomposer.arch.Parameter object.

    More About

    collapse all

    Definitions

    TermDefinitionApplicationMore 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:

    • Functional architecture describes the flow of data in a system.

    • Logical architecture describes the intended operation of a system.

    • Physical architecture describes the platform or hardware in a system.

    You can define parameters on the architecture level using the Parameter Editor.

    model

    A System Composer model is the file that contains architectural information, including components, ports, connectors, interfaces, and behaviors.

    Perform operations on a model:

    • Extract the root-level architecture contained in the model.

    • Apply profiles.

    • Link interface data dictionaries.

    • Generate instances from model architecture.

    A System Composer model is stored as an SLX file.

    Create Architecture Model with Interfaces and Requirement Links
    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 architectural 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. Transfer information between components with:

    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:

    • Component ports are interaction points on the component to other components.

    • Architecture ports are ports on the boundary of the system, whether the boundary is within a component or the overall architecture model.

    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

    TermDefinitionApplicationMore Information
    reference component

    A reference component is a component whose definition is a separate architecture model, Simulink® behavior model, or Simulink subsystem behavior. A reference component represents a logical hierarchy of other compositions.

    You can reuse compositions in the model using reference components. There are three types of reference components:

    • Model references are Simulink models.

    • Subsystem references are Simulink subsystems.

    • Architecture references are System Composer architecture models.

    parameter

    A parameter is an instance-specific value of a value type.

    Parameters are available for inlined architectures and components. Parameters are also available for components linked to model references or architecture references that specify model arguments. You can specify independent values for a parameter on each component.

    subsystem component

    A subsystem component is a Simulink subsystem that is part of the parent System Composer architecture model.

    Add Simulink subsystem behavior to a component to author a subsystem component in System Composer. You cannot synchronize and reuse subsystem components as Reference Component blocks because the component is part of the parent model.

    state chart

    A state chart diagram demonstrates the state-dependent behavior of a component throughout its state lifecycle and the events that can trigger a transition between states.

    Add Stateflow® chart behavior to describe a component using state machines. You cannot synchronize and reuse Stateflow chart behaviors as Reference Component blocks because the component is part of the parent model.

    Version History

    Introduced in R2022b