numerictype Object Properties

Data Type and Scaling Properties

All the properties of a numerictype object are writable. However, the numerictype properties of a fi object are not writable once the fi object has been created:

These properties are described in detail in the Property Reference. To learn how to specify properties for numerictype objects in Fixed-Point Toolbox™ software, refer to Setting numerictype Object Properties.

Setting numerictype Object Properties

Setting numerictype Properties at Object Creation

You can set properties of numerictype objects at the time of object creation by including properties after the arguments of the numerictype constructor function.

For example, to set the word length to 32 bits and the fraction length to 30 bits,

T = numerictype('WordLength', 32, 'FractionLength', 30)
 
T =
 

          DataTypeMode: Fixed-point: binary point scaling
                Signed: true
            WordLength: 32
        FractionLength: 30

Using Direct Property Referencing with numerictype Objects

You can reference directly into a property for setting or retrieving numerictype object property values using MATLAB® structure-like referencing. You do this by using a period to index into a property by name.

For example, to get the word length of T,

T.WordLength

ans =

32

To set the fraction length of T,

T.FractionLength = 31
 
T =
 

          DataTypeMode: Fixed-point: binary point scaling
                Signed: true
            WordLength: 32
        FractionLength: 31

Setting numerictype Properties in the Model Explorer

You can view and change the properties for any numerictype object defined in the MATLAB workspace in the Model Explorer. Open the Model Explorer by selecting View > Model Explorer in any Simulink® model, or by typing daexplr at the MATLAB command line.

The figure below shows the Model Explorer when you define the following numerictype objects in the MATLAB workspace:

T = numerictype
 
T =
 

          DataTypeMode: Fixed-point: binary point scaling
                Signed: true
            WordLength: 16
        FractionLength: 15

U = numerictype('DataTypeMode', 'Fixed-point: slope and bias')
 
U =
 

          DataTypeMode: Fixed-point: slope and bias scaling
                Signed: true
            WordLength: 16
                 Slope: 2^-15
                  Bias: 0

Select the Base Workspace node in the Model Hierarchy pane to view the current objects in the Contents pane. When you select a numerictype object in the Contents pane, you can view and change its properties in the Dialog pane.

  


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