# fixdt

Create `Simulink.NumericType` object describing a fixed-point or floating-point data type

## Syntax

``a = fixdt(Signed,WordLength)``
``a = fixdt(Signed,WordLength,FractionLength)``
``a = fixdt(Signed,WordLength,TotalSlope,Bias)``
``a = fixdt(Signed,WordLength,SlopeAdjustmentFactor,FixedExponent,Bias)``
``a = fixdt(DataTypeNameString)``
``a = fixdt(___,'DataTypeOverride','Off')``
``[a,IsScaledDouble] = fixdt(___)``

## Description

example

````a = fixdt(Signed,WordLength)` returns a `Simulink.NumericType` object that describes a fixed-point data type with the specified signedness and wordlength, and unspecified scaling. ```

example

````a = fixdt(Signed,WordLength,FractionLength)` returns a `Simulink.NumericType` object that describes a fixed-point data type with binary point scaling.```

example

````a = fixdt(Signed,WordLength,TotalSlope,Bias)` returns a `Simulink.NumericType` object that describes a fixed-point data type with slope and bias scaling.```

example

````a = fixdt(Signed,WordLength,SlopeAdjustmentFactor,FixedExponent,Bias)` returns a `Simulink.NumericType` object that describes a fixed-point data type with slope and bias scaling.```

example

````a = fixdt(DataTypeNameString)` returns a `Simulink.NumericType` object that describes an integer, fixed-point, or floating-point data type specified by the name of a data type.```

example

````a = fixdt(___,'DataTypeOverride','Off')` returns a `Simulink.NumericType` object with its `DataTypeOverride` parameter set to `Off`. The default value for this property is `Inherit`. You can specify the `DataTypeOverride` parameter after any combination of other input parameters.```

example

````[a,IsScaledDouble] = fixdt(___)` returns a `Simulink.NumericType` object that describes a fixed-point or floating-point data type and a flag that indicates whether the specified data type is of a scaled double data type.```

## Examples

collapse all

Create a signed `Simulink.NumericType `object with a word length of 16 bits and unspecified scaling.

`a = fixdt(1,16)`
```a = NumericType with properties: DataTypeMode: 'Fixed-point: unspecified scaling' Signedness: 'Signed' WordLength: 16 IsAlias: 0 DataScope: 'Auto' HeaderFile: '' Description: '' ```

Create a `Simulink.NumericType` object that describes a signed fixed-point data types with a word length of 16 bits and fraction length of 2 bits.

`a = fixdt(1,16,2)`
```a = NumericType with properties: DataTypeMode: 'Fixed-point: binary point scaling' Signedness: 'Signed' WordLength: 16 FractionLength: 2 IsAlias: 0 DataScope: 'Auto' HeaderFile: '' Description: '' ```

The real-world value of a slope bias scaled number is represented by:

`$\mathrm{real}\text{\hspace{0.17em}}\mathrm{world}\text{\hspace{0.17em}}\mathrm{value}=\left(\mathrm{slope}×\mathrm{integer}\right)+\mathrm{bias}$`

Create a `Simulink.NumericType `object that describes a signed fixed-point data type with a word length of 16 bits, slope of 2^-2, and bias of 4.

`a = fixdt(1,16,2^-2,4)`
```a = NumericType with properties: DataTypeMode: 'Fixed-point: slope and bias scaling' Signedness: 'Signed' WordLength: 16 Slope: 0.2500 Bias: 4 IsAlias: 0 DataScope: 'Auto' HeaderFile: '' Description: '' ```

Alternatively, the slope can by represented by:

`$\mathrm{slope}=\mathrm{slopeadjustmentfactor}×{2}^{\mathrm{fixedexponent}}$`

`a = fixdt(1,16,1,-2,4)`
```a = NumericType with properties: DataTypeMode: 'Fixed-point: slope and bias scaling' Signedness: 'Signed' WordLength: 16 Slope: 0.2500 Bias: 4 IsAlias: 0 DataScope: 'Auto' HeaderFile: '' Description: '' ```

The `DataTypeMode` property of the `Simulink.NumericType` object, `a`, is `slope and bias scaling.`

Use a data type name to create a `Simulink.NumericType` object that describes an 8-bit, unsigned, fixed-point data type and return a flag that indicates whether the object is of a scaled double data type.

`[a,IsScaledDouble] = fixdt('ufix8')`
```a = NumericType with properties: DataTypeMode: 'Fixed-point: binary point scaling' Signedness: 'Unsigned' WordLength: 8 FractionLength: 0 IsAlias: 0 DataScope: 'Auto' HeaderFile: '' Description: '' ```
```IsScaledDouble = logical 0 ```

The `IsScaledDouble` output returns `0`, which indicates that the data type of `a` is not a scaled double data type.

Create a `Simulink.NumericType` object with its `DataTypeOverride` property set to `Off`.

`a = fixdt(0,8,2,'DataTypeOverride','Off')`
```a = NumericType with properties: DataTypeMode: 'Fixed-point: binary point scaling' Signedness: 'Unsigned' WordLength: 8 FractionLength: 2 DataTypeOverride: 'Off' IsAlias: 0 DataScope: 'Auto' HeaderFile: '' Description: '' ```

## Input Arguments

collapse all

Signedness of the `Simulink.NumericType` object, specified as a numeric or logical `1` (`true`) or `0` (`false`). A value of `1`, or `true`, indicates a signed data type. A value of `0`, or `false`, indicates an unsigned data type.

Data Types: `logical`

Word length, in bits, of the `Simulink.NumericType` object, specified as a positive scalar.

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

Fraction length, in bits, of the `Simulink.NumericType` object, specified as a scalar.

`FractionLength` can be greater than `WordLength`. For more information, see Binary Point Interpretation (Fixed-Point Designer).

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

Slope of the scaling, specified as a scalar.

The following equation represents the real-world value of a slope bias scaled number:

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

Bias of the scaling, specified as a scalar.

The following equation represents the real-world value of a slope bias scaled number:

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

Slope adjustment factor of a slope bias scaled number, specified as a positive scalar.

The slope adjustment factor must be greater than or equal to 1 and less than 2. If you input a `SlopeAdjustmentFactor` outside this range, `fixdt` automatically applies a scaling normalization to the values of `SlopeAdjustmentFactor` and `FixedExponent` so that the revised slope adjustment factor is greater than or equal to 1 and less than 2, and maintains the value of the slope.

The following equation demonstrates the relationship between the slope, fixed exponent, and slope adjustment factor:

`$slope=slopeadjustmentfactor×{2}^{fixedexponent}$`

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

Fixed exponent of a slope bias scaled number, specified as a scalar.

The following equation demonstrates the relationship between the slope, fixed exponent, and slope adjustment factor:

`$slope=slopeadjustmentfactor×{2}^{fixedexponent}$`

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

Data type name, specified as a character vector.

The data type name can be either the name of a built-in Simulink® data type or the name of a fixed-point data type that conforms to the naming convention for fixed-point names established by the Fixed-Point Designer™ product. For more information, see Fixed-Point Data Type and Scaling Notation (Fixed-Point Designer).

Data Types: `char`

## Output Arguments

collapse all

Data type, returned as a `Simulink.NumericType` object.

Scaled double flag, returned as a logical that indicates whether the specified data type name is the name of a scaled double data type.