sfrac
CreateSimulink.NumericType
object describing signed fractional data type
Syntax
a = sfrac(WordLength
) a = sfrac(WordLength
,GuardBits
)
Description
sfrac(
返回一个WordLength
)Simulink.NumericType
object that describes the data type of a signed fractional data type with a word size given by
.WordLength
sfrac(
返回一个WordLength
,GuardBits
)Simulink.NumericType
object that describes the data type of a signed fractional number. The total word size is given by
withWordLength
bits located to the left of the binary point.GuardBits
The most significant (leftmost) bit is the sign bit. The default binary point for this data type is assumed to lie immediately to the right of the sign bit. If guard bits are specified, they lie to the left of the binary point and to right of the sign bit. For example, the structure for an 8-bit signed fractional data type with 4 guard bits is:
Note
sfrac
is a legacy function. In new code, usefixdt
instead. In existing code, replacesfrac(WordLength,GuardBits)
withfixdt(1,WordLength,(WordLength-1-GuardBits))
andsfrac(WordLength)
withfixdt(1,WordLength,(WordLength-1))
.
Examples
Define an 8-bit signed fractional data type with 4 guard bits. Note that the range of this data type is -24= -16 to (1 - 2(1 - 8)).24= 15.875.
a = sfrac(8,4)
a = NumericType with properties: DataTypeMode: 'Fixed-point: binary point scaling' Signedness: 'Signed' WordLength: 8 FractionLength: 3 IsAlias: 0 DataScope: 'Auto' HeaderFile: '' Description: ''