Quantcast

Documentation Center

  • Trial Software
  • Product Updates

Contents

Simulink.NumericType

Specify data type

Description

This class lets you specify a data type as follows:

  1. Create an instance of this class in the MATLAB® base workspace or a model workspace. To create a numeric type in a model workspace, you must disable the Is alias option.

  2. Set object properties to the properties of the custom data type.

  3. Assign the data type to all signals and parameters of your model that you want to conform to the data type.

Assigning a data type in this way allows you to change the data types of the signals and parameters in your model by changing the properties of the object that describe them. You do not have to change the model itself.

Property Dialog Box

Data type mode

Data type of this numeric type. The options are

Option

Description

Double

Same as the MATLAB double type.

Single

Same as the MATLAB single type.

Boolean

Same as the MATLAB boolean type.

Fixed-point: unspecified scaling

A fixed-point data type with unspecified scaling.

Fixed-point: binary point scaling

A fixed-point data type with binary-point scaling.

Fixed-point: slope and bias scaling

A fixed-point data type with slope and bias scaling.

Selecting a data type mode causes Simulink® software to enable controls on the dialog box (see below) that apply to the mode and to disable other controls that do not apply. Selecting a fixed-point data type mode might, depending on the other dialog box options that you select, cause the model to run only on systems that have a Fixed-Point Designer™ option installed.

Data type override

Data type override setting for this numeric type. The options are

Option

Description

Inherit (default)

Data type override setting for the context in which this numeric type is used (block, signal, Stateflow chart in Simulink) applies to this numeric type.

Off

Data type override setting does not affect this numeric type.

Is alias

If this option is selected for a workspace object of this type, Simulink software uses the name of the object as the data type for all objects that specify the object as its data type. Otherwise, Simulink software uses the data type mode of the data type as its name, or, if the data type mode is a fixed-point mode, Simulink software generates a name that encodes the type's properties, using the encoding specified by the Fixed-Point Designer product.

Data scope

Specifies whether the data type definition should be imported from, or exported to, a header file during code generation. The possible values are:

ValueAction
Auto (default)If no value is specified for Header file, export the type definition to model_types.h, where model is the model name.

If a value is specified for Header file, import the data type definition from the specified header file.
ExportedExport the data type definition to a header file, which can be specified in the Header file field. If no value is specified for Header file, the header file name defaults to type.h, wheretype is the data type name.
ImportedImport the data type definition from a header file, which can be specified in the Header file field. If no value is specified for Header file, the header file name defaults to type.h, wheretype is the data type name.

Header file

Name of a C header file from which a data type definition is imported, or to which a data type definition is exported, based on the value of Data scope. If this field is specified, the specified name is used during code generation for importing or exporting. If this field is empty, the value defaults to type.h if Data scope equals Imported or Exported, or defaults to model_types.h if Data scope equals Auto.

Description

Description of this data type. This field is intended for use in documenting this data type. Simulink software ignores it.

Signedness

Specifies whether the data type is signed or unsigned, or inherits its signedness. Set the option to Signed, Unsigned, or Auto. This option is enabled only for fixed-point data type modes.

Word-Length

Word length in bits of the fixed-point data type. This option is enabled only for fixed-point data type modes.

Fraction length

Number of bits to the right of the binary point. This option is enabled only if the data type mode is Fixed-point: binary point scaling.

Slope

Slope for slope and bias scaling. This option is enabled only if the data type mode is Fixed-point: slope and bias scaling.

Bias

Bias for slope and bias scaling. This option is enabled only if the data type mode is Fixed-point: slope and bias scaling. See the preceding figure.

Properties

Name

Access

Description

Bias

RW

Bias used for slope and bias scaling of a fixed-point data type. This field is intended for use by the Fixed-Point Designer product. (Bias)

DataScope

RW

A string specifying whether the data type definition should be imported from, or exported to, a header file during code generation. (Data scope)

DataTypeMode

RW

String that specifies the data type mode of this numeric type. Valid values are 'Double', 'Boolean', 'Single', 'Fixed-point: unspecified scaling', 'Fixed-point: binary point scaling', and 'Fixed-point: slope and bias scaling'. (Data type mode)

DataTypeOverride

RW

String that specifies the data type override mode. Valid values are Inherit and Off. (Data type override)

Description

RW

Description of this data type. (Description)

Fixedexponent

RW

Exponent used for binary point scaling. This property equals -FractionLength. Setting this property causes Simulink software to set the FractionLength and Slope properties accordingly, and vice versa. This property applies only if the DataTypeMode is Fixed-point: binary point scaling or Fixed-point: slope and bias scaling. It does not appear on the object's Property dialog box, but can be accessed from the MATLAB command prompt.

FractionLength

RW

Integer that specifies the size in bits of the fractional portion of the fixed-point number. This property equals -Fixedexponent. Setting this property causes Simulink software to set the Fixedexponent property accordingly, and vice versa. This field is intended for use by the Fixed-Point Designer product. (Fraction length)

HeaderFile

RW

A string that specifies the name of a C header file from which a data type definition is imported, or to which a data type definition is exported, during code generation. (Header file)

IsAlias

RW

Integer that specifies whether to use the name of this object as the name of the data type that it specifies. Valid values are 1 (yes) or 0 (no). (Is alias)

Signedness

RW

Boolean that specifies whether this data type is signed, unsigned, or inherits its signedness. Valid values are 1 (signed), 0 (unsigned), or Auto (inherit signedness). (Signedness)

Slope

RW

Slope for slope and bias scaling of fixed-point numbers. This property equals SlopeAdjustmentFactor * 2^Fixedexponent. If SlopeAdjustmentFactor is 1.0, Simulink software displays the value of this field as 2^SlopeAdjustmentFactor. Otherwise, it displays it as a numeric value. Setting this property causes Simulink software to set the Fixedexponent and SlopeAdjustmentFactor properties accordingly, and vice versa. This property appears only if DataTypeMode is Fixed-point: slope and bias scaling. (Slope)

SlopeAdjustmentFactor

RW

Slope for slope and bias scaling of fixed-point numbers. Setting this property causes Simulink software to adjust the Slope property accordingly, and vice versa. This property applies only if DataTypeMode is Fixed-point: slope and bias scaling. It does not appear on the object's Property dialog box, but can be accessed from the MATLAB command prompt.

WordLength

RW

Integer that specifies the word size of this data type. This field is intended for use by the Fixed-Point Designer product. This property appears only if DataTypeMode is Fixed-point. (Word Length)

Methods

NameDescription

isboolean

Determine whether data type is Boolean

Returns 1 when the DataTypeMode is 'Boolean', 0 otherwise.

isdouble

Determine whether data type is double precision

Returns 1 when the DataTypeMode is 'Double', 0 otherwise.

isfixed

Determine whether data type is fixed point

Returns 1 when the DataTypeMode is any of the fixed-point options, 0 otherwise. The fixed-point options are:

  • 'Fixed-point: unspecified scaling'

  • 'Fixed-point: binary point scaling'

  • 'Fixed-point: slope and bias scaling'

isfloat

Determine whether data type is floating point

Returns 1 when the DataTypeMode is 'Double' or 'Single', 0 otherwise.

isscalingbinarypoint

Determine whether data type has binary point scaling

Returns 1 when the data type has binary point scaling or trivial slope and bias scaling, 0 otherwise. Slope and bias scaling is trivial when the slope is an integer power of two and the bias is zero.

DataTypeMode is 'Fixed-point: binary point scaling'

isscalingslopebias

Determine whether data type has nontrivial slope and bias scaling

Returns 1 when the data type has nontrivial slope and bias scaling, 0 otherwise. Slope and bias scaling is trivial when the slope is an integer power of two and the bias is zero.

DataTypeMode is 'Fixed-point: slope and bias scaling'

isscalingunspecified

Determine whether data type has unspecified scaling

Returns 1 when the data type is fixed point and its scaling has not been specified, 0 otherwise.

DataTypeMode is 'Fixed-point: unspecified scaling'

issingle

Determine whether data type is single-precision

Returns 1 when the DataTypeMode is 'Single', 0 otherwise.

See Also

Generate Code Including User-Defined Data Types in the Embedded Coder® documentation

Was this topic helpful?