定点转换
将浮点代码转换为定点代码,优化定点数据类型(需要 Fixed-Point Designer™)
如果您有 Fixed-Point Designer 产品,为了符合目标硬件约束,请生成定点 C/C++ 代码。
类
coder.FixPtConfig | Floating-point to fixed-point conversion configuration object |
函数
coder | 打开 MATLAB Coder |
codegen | 从 MATLAB 代码生成 C/C++ 代码 |
coder.config | 创建代码生成配置对象 |
coder.approximation | Create function replacement configuration object |
coder.float2fixed.skip | Exclude functions from fixed-point conversion (自 R2024b 起) |
主题
自动定点转换工作流
- Automated Fixed-Point Conversion
Using the command line to perform automated fixed-point conversion. - Automated Fixed-Point Conversion Best Practices
Generate fixed-point code according to best practices. - MATLAB Language Features Supported for Automated Fixed-Point Conversion
For automated fixed-point conversion, use supported MATLAB® language features. - Fixed-Point Code for MATLAB Classes
Use supported constructs and coding style best practices for fixed-point conversion of MATLAB classes. - Convert MATLAB Code to Fixed-Point C Code
Generate fixed-point C code withcodegen. - Convert Fixed-Point Conversion Project to MATLAB Scripts
Use project settings for fixed-point conversion at the command line.
建议定点类型
- Specify Type Proposal Options
Specify options used when proposing types for automated fixed-point conversion. - Propose Fixed-Point Data Types Based on Simulation Ranges
Propose fixed-point data types based on simulation ranges using thecodegenfunction. - Propose Fixed-Point Data Types Based on Derived Ranges
Propose fixed-point data types based on static ranges using thecodegenfunction.
函数替换
- Replacing Functions Using Lookup Table Approximations
Generate lookup table approximations to replace custom functions or functions that are not supported for fixed point. - Replace the exp Function with a Lookup Table
Replace a function with a lookup table approximation in fixed-point code generated with thecodegenfunction. - Replace a Custom Function with a Lookup Table
Replace a custom function with a lookup table approximation function by using thecodegenfunction.
验证定点转换
- Visualize Differences Between Floating-Point and Fixed-Point Results
Use a custom plot function to compare the behavior of the generated fixed-point code against the behavior of the original floating-point MATLAB code. - Enable Plotting Using the Simulation Data Inspector
Inspect and compare floating-point and fixed-point logged input and output data. - Custom Plot Functions
Visualize numerical differences during fixed-point conversion. - Detect Overflows
Detect overflows at the command line.
故障排除
- Generated Fixed-Point Code
Avoid issues with generated fixed-point code. - Data Type Issues in Generated Code
Highlight potential data type issues in report.