Products & Services Industries Academia Support User Community Company

Learn more about Simulink   

sfrac - Create MATLAB structure describing signed fractional data type

Syntax

a = sfrac(TotalBits)
a = sfrac(TotalBits, GuardBits)

Description

sfrac(TotalBits) returns a MATLAB structure that describes the data type of a signed fractional number with a word size given by TotalBits.

sfrac(TotalBits, GuardBits) returns a MATLAB structure that describes the data type of a signed fractional number. The total word size is given by TotalBits with GuardBits bits located to the left of the binary point.

sfrac is automatically called when a signed fractional data type is specified in a block dialog box.

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:

Examples

Define an 8-bit signed fractional data type with 4 guard bits. Note that the range of this number is -24 = -16 to (1 - 2(1 - 8)).24 = 15.875:

a = sfrac(8,4)
a = 
        Class: 'FRAC'
     IsSigned: 1
     MantBits: 8
    GuardBits: 4

See Also

fixdt, float, sfix, sint, ufix, ufrac, uint

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS