Main Content

Simulink.ValueType

Specify properties of signals based on application-specific value types

Description

A Simulink.ValueType object is an application-specific set of properties that corresponds to a type of value, such as wind velocity. With ValueType objects, you specify the properties once and reuse that specification for each signal that represents the same type of value.

To create and modify ValueType objects in the base workspace or a data dictionary, you can use the Model Explorer or MATLAB® commands. You cannot store ValueType objects in model workspaces.

Specify a ValueType object:

  • At an interface with Inport, Outport, In Bus Element, or Out Bus Element blocks

  • In a model with Signal Specification blocks

  • In a Simulink.BusElement object

Use ValueType objects to validate the properties of a signal and enforce consistency between connected blocks at an interface.

Creation

Use either the Simulink.ValueType function described here or the Model Explorer to create a ValueType object.

Description

example

vt = Simulink.ValueType returns a ValueType object with default property values.

Properties

expand all

Data type, specified as a character vector or string scalar.

You can specify any of these options:

  • Built-in Simulink® data type — For example, specify 'single' or 'uint8'. See Data Types Supported by Simulink.

  • Fixed-point data type — Use the fixdt function. For example, specify 'fixdt(1,16,0)'.

  • Enumerated data type — Use the name of the type preceded by Enum:. For example, specify 'Enum: myEnumType'.

  • Custom data type — Use a MATLAB expression that specifies the type. For example, you can specify a Simulink.NumericType object whose DataTypeMode property is set to a value other than 'Fixed-point: unspecified scaling'.

Data Types: char | string

Minimum value, specified as a finite real double scalar.

Data Types: double

Maximum value, specified as a finite real double scalar.

Data Types: double

Physical unit, specified as a character vector or string scalar.

For more information, see Unit Specification in Simulink Models.

Example: 'inches'

Data Types: char | string

Numeric type, specified as 'real' or 'complex'.

Data Types: char | string

Dimensions, specified as a scalar or vector.

Data Types: double

Option to allow only fixed-size or variable-size signals, specified as 'Fixed' or 'Variable', respectively.

Data Types: char | string

Description, specified as a character vector or string scalar. Use the description to document information about the ValueType object, such as the kind of signal it applies to. This information does not affect Simulink processing.

Data Types: char | string

Examples

collapse all

In the MATLAB Command Window, define a reusable set of properties that correspond to wind velocity by using the Simulink.ValueType function.

Create a ValueType object with default properties.

windVelocity = Simulink.ValueType
windVelocity = 
  ValueType with properties:

          DataType: 'double'
               Min: []
               Max: []
              Unit: ''
        Complexity: 'real'
        Dimensions: 1
    DimensionsMode: 'Fixed'
       Description: ''

Specify the desired property values for wind velocity.

windVelocity.DataType = 'single';
windVelocity.Min = 11;
windVelocity.Max = 17;
windVelocity.Unit = 'm/s';
windVelocity.Dimensions = [2 4 3];
windVelocity.Description = 'Wind velocity value type'
windVelocity = 
  ValueType with properties:

          DataType: 'single'
               Min: 11
               Max: 17
              Unit: 'm/s'
        Complexity: 'real'
        Dimensions: [2 4 3]
    DimensionsMode: 'Fixed'
       Description: 'Wind velocity value type'

Introduced in R2021b