MATLAB Examples

Use derived range analysis to collect ranges that then can be used by the Fixed-Point Tool to propose fixed-point scaling.

Use the Fixed-Point Advisor (FPA) to prepare a floating-point model or subsystem for conversion to fixed point. After preparation, use the Fixed-Point Tool to convert the floating-point

Use the Fixed-Point Tool, which is launched automatically upon opening the model. The tool is a graphical user interface (GUI) that automates common tasks of collecting min-max range data

Use the FixPt To FixPt Inherited block. Because Simulink® propagates data types throughout a block diagram, fixed-point utility modeling can be templatized for multiple use scenarios.

This model shows how to convert signals between built-in and fixed-point data types and illustrates how fixed-point data types affect the representable precision and range. The

Convert from one fixed-point data type to another fixed-point data type. In this case the conversion is between sfix32_En2 and ufix8_En1, meaning:

Optimize fixed-point operations in generated code using minimum and maximum values that you specify in a model.

Control generation of multiword operations in generated code.

Control the generation of multiplication helper functions in the generated code.

Compute the QR decomposition of matrices using hardware-efficient MATLAB® code in Simulink®.

Use the function fixpt_look1_func_plot to find the maximum absolute error for the simple lookup table whose breakpoints are 0, 0.25, and 1. The corresponding Y data points of the lookup

Sample fixed-point implementations of a discrete lead filter and a discrete lag filter along with reference implementations in floating point.

This model shows how to exercise a custom C language S-function written to compute a fixed-point "product and sum" operation. To see the source code for the S-function, use the right-click

Find the approximation to an ideal function of y = sin(2*pi*x) over an input range [xmin,xmax] using a lookup table approach. Fixed-point applications often need to approximate a function

Implement a direct form filter in fixed point using fundamental building blocks such as Gain, Delay, and Sum.

A custom C language S-function written to generate a constant value. This operation is available in Simulink® with the "Constant" block, which can be used for comparison with this

Construct a fixed-point series cascade form filter using the fundamental building blocks of delay, sum, and gain.

Implement a parallel form filter in fixed point using fundamental building blocks such as Gain, Delay, and Sum.

This model shows how to propagate fixed-point data types in fixed-point S-Functions. It exercises a custom C language S-function written to enforce data types across multiple signals.

A custom C language S-function written to perform an arithmetic shift. This operation is available in Simulink® with the "Shift Arithmetic" block, which can be used for comparison with this

This model shows bit-true implementations of fixed-point direct type I and II filters with time-varying and time-invariant coefficients. These filters use the fundamental capabilities

Some of the features of Prelookup and Interpolation Using Prelookup blocks.

How Prelookup and Interpolation blocks share their parameter data in generated code.

Several ways to use S-functions to probe signal properties. Use this model for simulation only; it does not support code generation.

When you want to optimize for both memory and absolute tolerance, it is helpful to visualize the tradeoffs between the two. This example creates a lookup table approximation of the function

Optimize an existing Lookup Table block for memory efficiency. Open the model containing the Lookup Table block that you want to optimize.

Generate a memory-efficient lookup table that approximates the sin function. Define the approximation problem by creating a FunctionApproximation.Problem object.

Convert a neural network regression model in Simulink to fixed point using the Fixed-Point Tool and Lookup Table Optimizer and generate C code using Simulink Coder.

Convert a neural network regression model in Simulink to fixed point using the fxpopt function and Lookup Table Optimizer.

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

Contact your local office