Main Content

本页翻译不是最新的。点击此处可查看最新英文版本。

fixdt

创建描述定点或浮点数据类型的 Simulink.NumericType 对象

说明

示例

a = fixdt(Signed,WordLength) 返回 Simulink.NumericType 对象,该对象描述具有指定的符号性和字长以及未指定的定标的定点数据类型。

示例

a = fixdt(Signed,WordLength,FractionLength) 返回 Simulink.NumericType 对象,该对象描述具有二进制小数点定标的定点数据类型。

示例

a = fixdt(Signed,WordLength,TotalSlope,Bias) 返回 Simulink.NumericType 对象,该对象描述具有斜率和偏置定标的定点数据类型。

示例

a = fixdt(Signed,WordLength,SlopeAdjustmentFactor,FixedExponent,Bias) 返回 Simulink.NumericType 对象,该对象描述具有斜率和偏置定标的定点数据类型。

示例

a = fixdt(DataTypeNameString) 返回 Simulink.NumericType 对象,该对象描述由数据类型名称指定的整数、定点或浮点数据类型。

示例

a = fixdt(___,'DataTypeOverride','Off') 返回 DataTypeOverride 参数设置为 OffSimulink.NumericType 对象。此属性的默认值为 Inherit。您可以在其他输入参数的任意组合之后指定 DataTypeOverride 参数。

示例

[a,IsScaledDouble] = fixdt(___) 返回 Simulink.NumericType 对象,该对象描述定点或浮点数据类型以及指示指定的数据类型是否为定标双精度数据类型的标志。

示例

全部折叠

创建一个字长为 16 位、未指定定标的有符号 Simulink.NumericType 对象。

a = fixdt(1,16)
a = 
  NumericType with properties:

    DataTypeMode: 'Fixed-point: unspecified scaling'
      Signedness: 'Signed'
      WordLength: 16
         IsAlias: 0
       DataScope: 'Auto'
      HeaderFile: ''
     Description: ''

创建一个 Simulink.NumericType 对象,该对象描述一种字长为 16 位、小数长度为 2 位的有符号定点数据类型。

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: ''

斜率偏置定标数的真实值由下式表示:

realworldvalue=(slope×integer)+bias

创建一个 Simulink.NumericType 对象,该对象描述一种字长为 16 位、斜率为 2^-2、偏置为 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: ''

或者,斜率可以由下式表示:

slope=slopeadjustmentfactor×2fixedexponent

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: ''

Simulink.NumericType 对象 aDataTypeMode 属性是 slope and bias scaling

使用数据类型名称创建一个 Simulink.NumericType 对象,该对象描述一种 8 位无符号定点数据类型并返回一个标志,该标志指示该对象是否为定标双精度数据类型。

[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

IsScaledDouble 输出返回 0,这表明 a 的数据类型不是定标双精度数据类型。

创建一个 DataTypeOverride 属性设置为 OffSimulink.NumericType 对象。

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: ''

输入参数

全部折叠

Simulink.NumericType 对象的符号性,指定为数值或逻辑值 1 (true) 或 0 (false)。值 1true 表示有符号数据类型。值 0false 表示无符号数据类型。

数据类型: logical

Simulink.NumericType 对象的字长,以位为单位,指定为正标量。

数据类型: half | single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Simulink.NumericType 对象的小数长度,以位为单位,指定为标量。

FractionLength 可以大于 WordLength。有关详细信息,请参阅二进制小数点的解释 (Fixed-Point Designer)

数据类型: half | single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

定标的斜率,指定为标量。

以下方程表示斜率偏置定标数的真实值:

real world value = (slope×integer)+bias

数据类型: half | single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

定标的偏置,指定为标量。

以下方程表示斜率偏置定标数的真实值:

real world value = (slope×integer)+bias

数据类型: half | single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

斜率偏置定标数的斜率调整因子,指定为正标量。

斜率调整因子必须大于或等于 1 且小于 2。如果您输入的 SlopeAdjustmentFactor 超出此范围,fixdt 会自动对 SlopeAdjustmentFactorFixedExponent 的值应用定标归一化,以便修正后的斜率调整因子大于或等于 1 且小于 2 并保持斜率值。

以下方程说明斜率、固定指数和斜率调整因子之间的关系:

slope=slope adjustment factor×2fixed exponent

数据类型: half | single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

斜率偏置定标数的固定指数,指定为标量。

以下方程说明斜率、固定指数和斜率调整因子之间的关系:

slope=slope adjustment factor×2fixed exponent

数据类型: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

数据类型名称,指定为字符向量。

数据类型名称可以是内置 Simulink® 数据类型的名称,或者是符合 Fixed-Point Designer™ 产品制定的定点名称命名约定的定点数据类型名称。有关详细信息,请参阅定点数据类型和定标表示法 (Fixed-Point Designer)

数据类型: char

输出参数

全部折叠

数据类型,以 Simulink.NumericType 对象形式返回。

定标双精度标志,以逻辑值形式返回,指示指定的数据类型名称是否为定标双精度数据类型的名称。

版本历史记录

在 R2006a 之前推出

另请参阅

主题