| Stateflow User's Guide |
 |
Specifying Fixed-Point Data in Stateflow
You can specify fixed-point data in Stateflow as follows:
- Add data to Stateflow as described in Adding Data to the Data Dictionary.
- Set the properties for the data in the data properties dialog as described in Setting Data Properties in the Data Dialog. For fixed-point data, set the following fields:
- In the Type field, select fixpt.
- In the Stored Integer field, select the desired integer type to hold
.
-
Choose between the unsigned integer types uint8, uint16, and uint32, and the signed integer types int8, int16, int32.
- If you want binary-point-only scaling for a fixed-point data (see note below), select the optional Fraction length field. You specify the number of bits to the right of the binary point in this fixed-point data by entering an integer value in the field to the right (noninteger values that you enter for Fraction length are flagged immediately with red text). A positive value moves the binary point left of the rightmost bit (least significant bit) by that amount. A negative value moves the binary point further right of the rightmost bit by that amount.

- If you want to enter separate slope and bias values (see note below), select the Scaling option. In the field to the right, enter a two-element array, that is,
[s b], in which the first element, s, is the slope, and the second element, b, is the bias. The slope must be greater than zero (values that you enter for Fraction length that are less than 0 are flagged immediately with red text).
| Note
It is recommended that you use binary-point-only scaling whenever possible to simplify the implementation of fixed-point data in generated code. Operations with fixed-point data using binary-point-only scaling are performed with simple bit shifts and eliminate the expensive code implementations required for separate slope and bias values.
|
You can also specify a fixed-point constant indirectly in action language by using a fixed-point context-sensitive constant. See Fixed-Point Context-Sensitive Constants.
| How Stateflow Defines Fixed-Point Data | | Fixed-Point Context-Sensitive Constants |  |
© 1994-2005 The MathWorks, Inc.