Main Content

systemcomposer.parameter.ParameterDefinition

Parameter definition in System Composer

    Description

    A ParameterDefinition object describes a parameter definition in System Composer™. Set and get the properties of a parameter definition to edit and view the instance-specific parameters specified as model arguments on a referenced model.

    Creation

    Creating a ParameterDefinition object directly is not supported. A ParameterDefinition object is returned when you use the getParameterDefinition function.

    Properties

    expand all

    Element that owns definition, specified as a systemcomposer.arch.Architecture object.

    Parameter name, specified as a character vector or string. This property must be a valid MATLAB® identifier.

    Example: "AirSpeed"

    Data Types: char | string

    Parameter data type, specified as a character vector or string. This property must be a valid MATLAB data type.

    Data Types: char | string

    Parameter dimensions, specified as a character vector or string.

    Data Types: char | string

    Parameter units, specified as a character vector or string.

    Data Types: char | string

    Parameter minimum, specified as a character vector or string.

    Data Types: char | string

    Parameter maximum, specified as a character vector or string.

    Data Types: char | string

    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.

    Open mAxleArch Architecture Model

    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 RightWheel and LeftWheel Components

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

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

    Get Parameter Names on RightWheel Component

    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
        "Pressure"    "Diameter"    "Wear"
    
    

    Get Parameter Definition on RightWheel Component for Pressure Parameter

    Get the parameter definition for the Pressure parameter on the RightWheel component architecture.

    paramDefinition = rightWheelComp.Architecture.getParameterDefinition(paramNames(1))
    paramDefinition = 
      ParameterDefinition with properties:
    
               Name: 'Pressure'
               Type: 'double'
               Unit: 'psi'
         Complexity: 'real'
         Dimensions: '[1  1]'
              Value: '32'
                Min: ''
                Max: ''
        Description: ''
              Owner: [1×1 systemcomposer.arch.Architecture]
    
    

    Get Parameter Values for RightWheel and LeftWheel Components

    Get the parameter values for the RightWheel and LeftWheel components.

    RightWheel Parameters

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

    LeftWheel Parameters

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

    Get Evaluated Parameter Values for RightWheel and LeftWheel Components

    Get the evaluated parameter values for the RightWheel and LeftWheel components.

    Evaluated RightWheel Parameters

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

    Evaluated LeftWheel Parameters

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

    Set Parameter Value and Units for Pressure Parameter on LeftWheel Component

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

    Current Values for Pressure on LeftWheel

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

    New Values for Pressure on LeftWheel

    leftWheelComp.setParameterValue("Pressure","2000")
    leftWheelComp.setUnit("Pressure","mbar")
    [paramValue,paramUnits,isDefault] = leftWheelComp.getParameterValue("Pressure")
    paramValue = 
    '2000'
    
    paramUnits = 
    'mbar'
    
    isDefault = logical
       0
    
    

    Revert Pressure Parameter on LeftWheel to Default Value

    leftWheelComp.resetParameterToDefault("Pressure")

    Save Models

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

    More About

    expand all

    Version History

    Introduced in R2022a