| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Fixed-Point Toolbox |
| Contents | Index |
| Learn more about Fixed-Point Toolbox |
| On this page… |
|---|
Example: Constructing a numerictype Object with Property Name and Property Value Pairs |
numerictype objects define the data type and scaling attributes of fi objects, as well as Simulink signals and model parameters. You can create numerictype objects in Fixed-Point Toolbox software in one of two ways:
You can use the numerictype constructor function to create a new object.
You can use the numerictype constructor function to copy an existing numerictype object.
To get started, type
T = numerictype
to create a default numerictype object.
T =
DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 16
FractionLength: 15
To see all of the numerictype object syntaxes, refer to the numerictype constructor function reference page.
The following examples show different ways of constructing numerictype objects. For more examples of constructing numerictype objects, see the Examples on the numerictype constructor function reference page.
When you create a numerictype object using property name and property value pairs, Fixed-Point Toolbox software first creates a default numerictype object, and then, for each property name you specify in the constructor, assigns the corresponding value.
This behavior differs from the behavior that occurs when you use a syntax such as T = numerictype(s,w), where you only specify the property values in the constructor. Using such a syntax results in no default numerictype object being created, and the numerictype object receives only the assigned property values that are specified in the constructor.
The following example shows how the property name/property value syntax creates a slightly different numerictype object than the property values syntax, even when you specify the same property values in both constructors.
To demonstrate this difference, suppose you want to create an unsigned numerictype object with a word length of 32 bits.
First, create the numerictype object using property name/property value pairs.
T1 = numerictype('signed',0,'wordlength',32)
T1 =
DataTypeMode: Fixed-point: binary point scaling
Signedness: Unsigned
WordLength: 32
FractionLength: 15The numerictype object T1 has the same DataTypeMode and FractionLength as a default numerictype object, but the WordLength and Signed properties are overwritten with the values you specified.
Now, create another unsigned 32 bit numerictype object, but this time specify only property values in the constructor.
T2 = numerictype(0,32)
T2 =
DataTypeMode: Fixed-point: unspecified scaling
Signedness: Unsigned
WordLength: 32Unlike T1, T2 only has the property values you specified. The DataTypeMode of T2 is Fixed-Point: unspecified scaling, so no fraction length is assigned.
fi objects cannot have unspecified numerictype properties. Thus, all unspecified numerictype object properties become specified at the time of fi object creation.
To copy a numerictype object, simply use assignment as in the following example:
T = numerictype;
U = T;
isequal(T,U)
ans =
1When you are working with M-files, you can build your numerictype object constructors using the Insert numerictype Constructor dialog box. After specifying the properties of the numerictype object in the dialog box, you can insert the prepopulated numerictype object constructor string at a specific location in your M-file.
For example, to create a signed numerictype object with binary-point scaling, a word length of 32 bits and a fraction length of 30 bits, perform the following steps:
Open the Insert numerictype Constructor dialog box by selecting Tools > Fixed-Point Toolbox > Insert numerictype Constructor from the editor menu.
Use the edit boxes and drop-down menus to specify the following properties of the numerictype object:
Data type mode = Fixed-point: binary point scaling
Signedness = Signed
Word length = 32
Fraction length = 30

To insert the numerictype object constructor string into your M-file, place your cursor at the desired location in the M-file, and click OK on the Insert numerictype Constructor dialog box. Clicking OK closes the Insert numerictype Constructor dialog box and automatically populates the numerictype object constructor string in your M-file:
![]()
![]() | Working with numerictype Objects | numerictype Object Properties | ![]() |

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-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |