Skip to Main Content Skip to Search
Product Documentation

sfi - Construct signed fixed-point numeric object

Syntax

a = sfi
a = sfi(v)
a = sfi(v,w)
a = sfi(v,w,f)
a = sfi(v,w,slope,bias)
a = sfi(v,w,slopeadjustmentfactor,fixedexponent,bias)

Description

You can use the sfi constructor function in the following ways:

fi objects created by the sfi constructor function have the following general types of properties:

These properties are described in detail in fi Object Properties in the Properties Reference.

Data Properties

The data properties of a fi object are always writable.

These properties are described in detail in fi Object Properties.

fimath Properties

When you create a fi object with the sfi constructor function, that fi object does not have a local fimath object. You can attach a fimath object to that fi object if you do not want to use the default fimath settings. For more information, see Working with fimath Objects in the Fixed-Point Toolbox User's Guide.

The following fimath properties are always writable and, by transitivity, are also properties of a fi object.

These properties are described in detail in fimath Object Properties.

numerictype Properties

When you create a fi object, a numerictype object is also automatically created as a property of the fi object.

numerictype — Object containing all the data type information of a fi object, Simulink signal or model parameter

The following numerictype properties are, by transitivity, also properties of a fi object. The properties of the numerictype object become read only after you create the fi object. However, you can create a copy of a fi object with new values specified for the numerictype properties.

For further details on these properties, see numerictype Object Properties.

Examples

Example 1

For example, the following creates a signed fi object with a value of pi, a word length of 8 bits, and a fraction length of 3 bits:

a = sfi(pi,8,3)

a =
 
    3.1250

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Signed
            WordLength: 8
        FractionLength: 3

Default fimath properties are associated with a. When a fi object does not have a local fimath object, no fimath object properties are displayed in its output. To determine whether a fi object has a local fimath object, use the isfimathlocal function.

isfimathlocal(a)

ans =
     0

A returned value of 0 means the fi object does not have a local fimath object. When the isfimathlocal function returns a 1, the fi object has a local fimath object.

Example 2

The value v can also be an array:

a = sfi((magic(3)/10),16,12) 

a =
 
    0.8000    0.1001    0.6001
    0.3000    0.5000    0.7000
    0.3999    0.8999    0.2000

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Signed
            WordLength: 16
        FractionLength: 12

Example 3

If you omit the argument f, it is set automatically to the best precision possible:

a = sfi(pi,8) 

a =
 
    3.1563

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Signed
            WordLength: 8
        FractionLength: 5

Example 4

If you omit w and f, they are set automatically to 16 bits and the best precision possible, respectively:

a = sfi(pi) 

a =
 
    3.1416

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Signed
            WordLength: 16
        FractionLength: 13

See Also

fi | fimath | fipref | isfimathlocal | numerictype | quantizer | ufi

  


Free Early Verification Kit

Learn how to apply early verification to your development process through these technical resources.

How much time do you spend on testing to ensure implementation meets system-level requirements?

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