Main Content

Specify Fixed-Point Data Types

Simulink® allows you to create models that use fixed-point numbers to represent signals and parameter values. Use of fixed-point data can reduce the memory requirements and increase the speed of code generated from a model.

To execute a model that uses fixed-point numbers, you must have the Fixed-Point Designer™ product installed on your system. Specifically, you must have the product to:

  • Update a Simulink diagram (Ctrl+D) containing fixed-point data types

  • Run a model containing fixed-point data types

  • Generate code from a model containing fixed-point data types

  • Log the minimum and maximum values produced by a simulation

  • Automatically scale the output of a model using the autoscaling tool

If the Fixed-Point Designer product is not installed on your system, you can execute a fixed-point model as a floating-point model by enabling automatic conversion of fixed-point data to floating-point data during simulation. See Overriding Fixed-Point Specifications for details.

If you do not have the Fixed-Point Designer product installed and do not enable automatic conversion of fixed-point to floating-point data, an error occurs if you try to execute a fixed-point model.

Note

You do not need the Fixed-Point Designer product to edit a model containing fixed-point blocks, or to use the Data Type Assistant to specify fixed-point data types, as described in Specifying a Fixed-Point Data Type.

Fixed-point data types that resolve to a base integer type do not require a Fixed-Point Designer license. For example, a block or signal that specifies a data type of fixdt(1,8,0), which is equivalent to the int8 built-in type will not check out a Fixed-Point Designer license.

Overriding Fixed-Point Specifications

Most of the functionality in the Fixed-Point Tool is for use with Fixed-Point Designer. However, even if you do not have Fixed-Point Designer, you can configure data type override settings to simulate a model that specifies fixed-point data types. In this mode, Simulink temporarily overrides fixed-point data types with floating-point data types when simulating the model.

Note

If you use fi (Fixed-Point Designer) objects or embedded numeric data types in your model or workspace, you might introduce fixed-point data types into your model. You can set fipref (Fixed-Point Designer) to prevent the checkout of a Fixed-Point Designer license.

To simulate a model without using Fixed-Point Designer, enter the following at the command line.

set_param(gcs, 'DataTypeOverride', 'Double', ...
'DataTypeOverrideAppliesTo', 'AllNumericTypes')

If you use fi objects or embedded numeric data types in your model, set the fipref DataTypeOverride property to TrueDoubles or TrueSingles (to be consistent with the model-wide data type override setting) and the DataTypeOverrideAppliesTo property to All numeric types.

For example, at the MATLAB® command line, enter:

 p = fipref('DataTypeOverride', 'TrueDoubles', ...
		'DataTypeOverrideAppliesTo', 'AllNumericTypes');

For these blocks, data type override is not supported.

  • Stateflow Chart blocks that use MATLAB as the action language

  • State Transition Table blocks that use MATLAB as the action language

  • Truth Table blocks that use MATLAB as the action language

  • Test Sequence block

  • MATLAB Function block

  • MATLAB Discrete-Event System block

  • Requirements Table block

See Also

|

Related Topics