量化
定点数据类型的精度、范围和定标
当使用浮点算术开发动态系统时,您通常不必担心数值限制,因为浮点数据类型具有精度高、范围广的特点。相反,当使用定点算术开发动态系统时,您必须考虑以下因素:
量化
会对定点值进行舍入。因此,输出到被控对象的信号和输入到控制系统的信号不具备与理想的离散时间信号相同的特性。
溢出
将两个足够大的负值或正值相加,会产生超出表示范围的结果。
计算噪声
由实现中各项的舍入导致的累积误差会引入噪声。
极限环
在理想系统中,对于常量输入,稳定传递函数(数字滤波器)的输出接近某个常量。通过量化,当输出在两个稳态值之间振荡时会出现极限环。
主题
定标、范围和精度
- 定标
定点数的动态范围比具有相同字长的浮点数小得多。为避免溢出情况并最大限度地减少量化误差,必须对定点数进行定标。 - 计算斜率和偏置
描述斜率偏置定标以及如何计算它。 - Net Slope and Net Bias Precision
Net slope and bias precision, detecting precision loss, underflow, and overflow. - Determine the Range of Fixed-Point Numbers
Fixed-point variables have a limited range because digital systems represent numbers with a finite number of bits. - Recommendations for Arithmetic and Scaling
Scaling in your fixed-point design based on the limitations of fixed-point arithmetic. - Maximize Precision
To maximize precision, make the slope as small as possible while keeping the range adequately large. - 检测定点常量精度损失
此示例说明如何检测定点常量精度损失。
量化
- 算术运算
执行定点算术时,选择数据类型和定标以获得最佳结果。 - 舍入模式
了解 Fixed-Point Designer™ 中可用的不同舍入模式。 - Choose a Rounding Mode
What to consider when choosing a rounding mode.
溢出
- 饱和与绕回
饱和与绕回描述某些处理器处理溢出情况的一种特殊方式。 - Underflow and Overflow Logging Using fipref
Examples of usingfiprefobjects to set logging preferences forfiobjects. - 处理 Simulink 模型中的溢出
控制当模型包含溢出时收到的警告消息。 - 保护位
通过向二进制字追加适当数量的保护位来消除可能的溢出。
