Documentation

sfrac

CreateSimulink.NumericTypeobject describing signed fractional data type

Syntax

a = sfrac(WordLength) a = sfrac(WordLength,GuardBits)

Description

sfrac(WordLength)返回一个Simulink.NumericTypeobject that describes the data type of a signed fractional data type with a word size given byWordLength.

sfrac(WordLength,GuardBits)返回一个Simulink.NumericTypeobject that describes the data type of a signed fractional number. The total word size is given byWordLengthwithGuardBitsbits located to the left of the binary point.

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

sfracis a legacy function. In new code, usefixdtinstead. 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: ''

Introduced before R2006a

Was this topic helpful?