Main Content

Simulink.dictionary.archdata.NumericType

Edit Simulink numeric types in Simulink data dictionary

Since R2023b

    Description

    Use a Simulink.dictionary.archdata.NumericType object to represent a Simulink.NumericType object in the Architectural Data section of a data dictionary.

    Creation

    You can add a Simulink.dictionary.archdata.NumericType object to a data dictionary in two ways.

    • Interactively create a Simulink.dictionary.archdata.NumericType object by using the Architectural Data Editor.

    • Programmatically create a Simulink.dictionary.archdata.NumericType object by using the addNumericType function.

    archDataObj = Simulink.dictionary.archdata.create("dataDictionary.sldd");
    numeric = addNumericType(archDataObj,"myNumeric")
    numeric = 
    
      NumericType with properties:
    
                    Name: 'myNumeric'
            DataTypeMode: 'Double'
        DataTypeOverride: 'Inherit'
                 IsAlias: 0
             Description: ''
                   Owner: [1×1 Simulink.dictionary.ArchitecturalData]

    Properties

    expand all

    Bias for slope and bias scaling of a fixed-point data type (Fixed-Point Designer™), specified as a real number.

    If you use a number with a data type other than double to set the value, Simulink® converts the value to double.

    This property is accessible only if DataTypeMode is set to "Fixed-point: slope and bias scaling".

    Example: 3

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

    Specification to generate or import the type definition (typedef) in the generated code (Simulink Coder™), specified as 'Auto', 'Exported', or 'Imported'.

    This table shows the effect of each option.

    ValueAction
    'Auto' (default)

    If no value is specified for HeaderFile, export the type definition to model_types.h, where model is the model name.

    If a value is specified for HeaderFile, import the data type definition from the specified header file.

    'Exported'Export the data type definition to a header file, which can be specified in the HeaderFile property. If no value is specified for the HeaderFile, the header file name defaults to type.h, where type is the data type name.
    'Imported'Import the data type definition from a header file, which can be specified in the HeaderFile property. If no value is specified for HeaderFile, the header file name defaults to type.h, where type is the data type name.

    Set the data scope to "Imported" or "Exported" to avoid potential MISRA C™:2012 violations.

    For more information, see Control File Placement of Custom Data Types (Embedded Coder).

    Data type of the numeric type object, specified as a string scalar or character vector.

    • "Double" — Same as the MATLAB double type.

    • "Single" — Same as the MATLAB single type.

    • "Half" — Half-precision floating-point type.

    • "Boolean" — Same as the MATLAB boolean type.

    • "Fixed-point: binary point scaling" — A fixed-point data type with binary-point scaling that enables properties Signedness, WordLength, and FractionLength.

    • "Fixed-point: slope and bias scaling" — A fixed-point data type with slope and bias scaling that enables properties Bias, Signedness, Slope, and WordLength.

    • "Fixed-point: unspecified scaling" — A fixed-point data type with unspecified scaling that enables properties Signedness, and WordLength.

    Example: set(numeric,"DataTypeMode","Fixed-point: binary point scaling");

    Data Types: char | string

    Option to inherit the data type from another source, specified as either "Inherit" or "Off".

    Example: set(numeric,"DataTypeOverride","Off")

    Data Types: char | string

    Custom description of the numeric type, specified as a character vector.

    Example: 'This numeric type is a double, and inherits its data type.'

    Data Types: char | string

    Bit length of the fractional portion of a fixed-point number (Fixed-Point Designer), specified as an integer.

    If you use a number with a data type other than double to set the value, Simulink converts the value to double.

    This property is accessible only if DataTypeMode is set to "Fixed-point: binary point scaling".

    Example: 8

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

    Name of the header file that contains the type definition (typedef) in the generated code, specified as a character vector. If this property is specified, the specified name is used during code generation for importing or exporting. If this property is empty, the value defaults to type.h if DataScope is set to "Imported" or "Exported", or defaults to model_types.h if DataScope is set to "Auto".

    By default, the generated #include directive uses the preprocessor delimiter " instead of < and >. To generate the directive #include <myTypes.h>, specify HeaderFile as '<myTypes.h>'.

    For more information, see Control File Placement of Custom Data Types (Embedded Coder).

    Example: '<myHdr.h>'

    Example: 'myHdr'

    Example: 'myHdr.hpp'

    Data Types: char | string

    Option to specify the numeric data type as an alias, specified as a numeric or logical 1 or true, or 0 or false.

    Example: set(numeric,"IsAlias",1)

    Data Types: logical

    Name of the numeric type object, specified as a character vector or string scalar.

    Example: addNumericType(archDataObj,"myNumericType")

    Data Types: char | string

    Architectural Data section containing the numeric type, specified as a Simulink.dictionary.ArchitecturalData object.

    Example: Owner: [1×1 Simulink.dictionary.ArchitecturalData]

    Signedness of a fixed-point data type (Fixed-Point Designer), specified as 'Signed', 'Unsigned', or 'Auto' (inherit signedness).

    This property is accessible only if DataTypeMode is set to one of these values:

    • "Fixed-point: binary point scaling"

    • "Fixed-point: slope and bias scaling"

    • "Fixed-point: unspecified scaling"

    Data Types: char

    Slope for slope and bias scaling of a fixed-point data type (Fixed-Point Designer), specified as a real number.

    If you use a number with a data type other than double to set the value, Simulink converts the value double.

    This property is accessible only if DataTypeMode is set to "Fixed-point: slope and bias scaling".

    Example: 5.2

    Example: 2^9

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

    Word size in bits of a fixed-point (Fixed-Point Designer) or integer data type, specified as an integer.

    This property is accessible only if DataTypeMode is set to one of these values:

    • "Fixed-point: binary point scaling"

    • "Fixed-point: slope and bias scaling"

    • "Fixed-point: unspecified scaling"

    Example: 8

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

    Object Functions

    moveToDictionaryMove architectural data of Simulink data dictionary to another data dictionary
    moveToDesignDataMove interfaces, data types, and constants in Architectural Data section of Simulink data dictionary to design data
    destroyDelete data element and remove from data interface
    showView architectural data of Simulink data dictionary in Architectural Data Editor

    Examples

    collapse all

    To add a Simulink.NumericType object with a specified name to the data dictionary, use the addNumericType function. For an example that shows more of the workflow for related functions, see Store Data in Architectural Data Section Programmatically.

    Create or open a data dictionary. This example uses a previously created data dictionary MyInterfaces.sldd.

    dictName = "MyInterfaces.sldd";
    archDataObj = Simulink.dictionary.archdata.open(dictName);
    

    Add numeric types using the addNumericType function.

    myNumericType = addNumericType(archDataObj,"numType")
    myNumericType = 
    
      NumericType with properties:
    
                    Name: 'numType'
            DataTypeMode: 'Double'
        DataTypeOverride: 'Inherit'
                 IsAlias: 0
             Description: ''
                   Owner: [1×1 Simulink.dictionary.ArchitecturalData]

    Specify the name, and base type using either input arguments of the function or the created numeric type object.

    set(myNumericType,"Name","myNumericBinaryPointScale");
    set(myNumericType,"DataTypeMode","Fixed-point: binary point scaling");

    You can use Simulink.NumericType objects to define Simulink.dictionary.archdata.NumericType objects.

    Create a Simulink.NumericType object referencing a fixed-point data type.

    mySimulinkNum = Simulink.NumericType;
    mySimulinkNum.DataTypeMode = "Single"
    mySimulinkNum.Description = "A numeric to be stored as architectural data."
    
    mySimulinkNum = 
    
      NumericType with properties:
    
        DataTypeMode: 'Double'
             IsAlias: 0
           DataScope: 'Auto'
          HeaderFile: ''
         Description: ''

    Add the Simulink.NumericType object to the Architectural Data section of a data dictionary by using the addNumericType function.

    archDataObj = Simulink.dictionary.archdata.open("myDataTypeDict.sldd");
    myNumericType = addNumericType(archDataObj,"archDataNum",...
        "SimulinkNumericType",mySimulinkNum)
    
    myNumericType = 
    
      NumericType with properties:
    
                    Name: 'archDataNum'
            DataTypeMode: 'Single'
        DataTypeOverride: 'Inherit'
                 IsAlias: 0
             Description: 'A numeric to be stored as architectural data.'
                   Owner: [1×1 Simulink.dictionary.ArchitecturalData]

    Version History

    Introduced in R2023b