Best Practices for Working with the MATLAB Function Block in Automated Fixed-Point Conversion Workflows
Follow these best practices when you use automated fixed-point conversion workflows on
models containing MATLAB Function blocks, including the optimized and
iterative fixed-point conversion workflows in the Fixed-Point Tool, the DataTypeWorkflow.Converter object
workflow, and the fxpopt function.
Do Not Edit MATLAB Function Block
Avoid editing the MATLAB Function block during the fixed-point conversion process.
Do not use the Save As option to save the MATLAB Function block with a different name. If you do, you might lose existing results for the original block.
Do not edit the MATLAB® code in the MATLAB Function block while collecting range information. Editing the code causes problems if you try to merge results.
Do not edit the fixed-point variant of your MATLAB Function block algorithm. Use the code view to edit the floating-point variant of your MATLAB code and reconvert to fixed-point data types.
Do Not Use Unsupported MATLAB Function Block Features
Some features of the MATLAB Function block are not supported for automated fixed-point conversion workflows. For a successful conversion, only use modeling constructs supported for automated fixed-point conversion.
For a list of features supported and not supported for automated fixed-point conversion workflows, see MATLAB Language Features Supported for Automated Fixed-Point Conversion.
Variable and structure names must be less than 2048 characters long.
Identify and Replace Unsupported Functions in MATLAB Function Blocks
Some functions used in MATLAB Function blocks, such as
sinh and exp, are not supported for
automated fixed-point conversion.
In R2025a: In the command-line workflow using the DataTypeWorkflow.Converter
object, use the getUnsupportedFunctionsForSystem function to identify unsupported
functions in MATLAB Function blocks. Then use the DataTypeWorkflow.FunctionReplacement object to specify and manage
custom function or lookup table replacements for unsupported functions during data
type conversion using DataTypeWorkflow.Converter.
For an example, see Replace Function in MATLAB Function Block with Lookup Table Approximation and Convert to Fixed Point.
In R2025b: In the Fixed-Point Tool, unsupported functions
are flagged in the preparation stage of conversion by the MATLAB Function Block Best Practices check. In
the iterative fixed-point conversion workflow of the Fixed-Point Tool,
when your system under design includes MATLAB Function blocks that
use unsupported functions, the Setup pane includes a
Function Replacement section where you can specify
replacements for unsupported functions. For more information, see Use the Fixed-Point Tool to Find and Replace Unsupported Functions in MATLAB Function Blocks.
Alternatively, use coder.float2fixed.skip inside the MATLAB Function
block to exclude the unsupported function from conversion.
See Also
MATLAB Language Features Supported for Automated Fixed-Point Conversion