Main Content

fixed.DataSpecification

Specify properties of data to generate

Description

Use the fixed.DataSpecification and fixed.DataGenerator objects to generate simulation inputs to test the full operating range of your designs.

Creation

Description

example

dataspec = fixed.DataSpecification(numerictype) creates a DataSpecification object with default property values and data type specified by numerictype.

example

dataspec = fixed.DataSpecification(numerictype, Name,Value)creates a DataSpecification object with data type specified by numerictype, and additional properties specified as Name,Value pair arguments.

Input Arguments

expand all

Data type of the generated data, specified as a string or character vector that evaluates to a numeric data type, or as a Simulink.NumericType or numerictype object.

Example: dataspec = fixed.DataSpecification('double')

Example: dataspec = fixed.DataSpecification('fixdt(1,16,4)')

Example: dataspec = fixed.DataSpecification(Simulink.NumericType);

Properties

expand all

Data type of the generated data, specified as a string or character vector that evaluates to a numeric data type, or as a Simulink.NumericType or numerictype object.

This property cannot be edited after construction.

Numeric intervals in which to generate numeric data, specified as a fixed.Interval object, an array of fixed.Interval objects, or a cell array containing inputs to the fixed.Interval constructor.

If you do not specify an interval, the default interval uses end points equal to the minimum and maximum representable values of the specified numeric type.

Example: dataspec.Intervals = {-1,1};

Example: dataspec.Intervals = fixed.Interval(-1,1);

Whether to exclude denormal numbers from generated data, specified as a logical.

This property is only applicable when the DataTypeStr property is a floating-point type.

Data Types: logical

Whether to exclude negative zero from generated data, specified as a logical.

This property is only applicable when the DataTypeStr property is a floating-point type.

Data Types: logical

Values to include in the generated data, specified as a scalar, vector, matrix, or multidimensional array. If the values specified in MandatoryValues are outside the range of the data type specified in DataTypeStr, the values are saturated to the nearest representable value.

Example: dataspec.MandatoryValues = [-215, 216];

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical | fi

Complexity of the generated data, specified as either 'real' or 'complex'.

Example: dataspec.Complexity = 'complex';

Data Types: char | string

Dimension of the generated data, specified as a positive scalar integer or row vector of positive integers.

Example: dataspec.Dimensions = 3;

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Object Functions

containsDetermine whether value domain of a DataSpecification object contains a specified value
applyOnRootInport(To be removed) Apply properties to Inport block

Examples

collapse all

Create a fixed.DataSpecification object with default property values and an int16 data type.

dataspec = fixed.DataSpecification('int16')
dataspec = 
  fixed.DataSpecification with properties:

          DataTypeStr: 'int16'
            Intervals: [-32768,32767]
      MandatoryValues: <empty>
           Complexity: 'real'
           Dimensions: 1

The default interval of the DataSpecification object is equal to the range of the data type specified in the constructor.

Create a fixed.Interval object specifying a range of -π to π.

interval = fixed.Interval(-pi,pi)
interval = 
    [-3.1416,3.1416]

  1x1 fixed.Interval with properties:

              LeftEnd: -3.1416
             RightEnd: 3.1416
         IsLeftClosed: true
        IsRightClosed: true

Create a DataSpecification object using this interval and a data type of fixdt(1,16,10).

dataspec = fixed.DataSpecification('fixdt(1,16,10)','Intervals',interval)
dataspec = 
  fixed.DataSpecification with properties:

          DataTypeStr: 'sfix16_En10'
            Intervals: [-3.1416,3.1416]
      MandatoryValues: <empty>
           Complexity: 'real'
           Dimensions: 1

Alternatively, you can specify the interval as a cell array of inputs to the fixed.Interval constructor. The following code generates an equivalent DataSpecification object.

dataspec = fixed.DataSpecification('fixdt(1,16,10)','Intervals',{-pi,pi})
dataspec = 
  fixed.DataSpecification with properties:

          DataTypeStr: 'sfix16_En10'
            Intervals: [-3.1416,3.1416]
      MandatoryValues: <empty>
           Complexity: 'real'
           Dimensions: 1

You can include NaN and Inf values in the generated data by specifying these values as intervals in an Interval object.

The following code creates a DataSpecification object that references an array of interval objects that include the values -Inf, Inf, NaN, and the range [-1, 1].

dataspec = fixed.DataSpecification('single', 'Intervals',...
 {{-Inf}, {Inf}, {NaN}, {-1,1}})
dataspec = 

  fixed.DataSpecification with properties:

          DataTypeStr: 'single'
            Intervals: [-Inf] [-1,1] [Inf] [NaN]
     ExcludeDenormals: false
  ExcludeNegativeZero: false
      MandatoryValues: <empty>
           Complexity: 'real'
           Dimensions: 1
Introduced in R2019b