- Increase the permitted range for your fixed point objects, so that they do not overflow; Or
- Re-examine the mathematics of your equations to figure out why you are getting overflows, and repair the algorithm
Wrap/Saturate on overflow
32 views (last 30 days)
Show older comments
Hi there,
I'm trying to simulate a control algorithm with the fixed point tool. When I apply the fixed point data types and try to simulate the model, I get many wrap/saturate on overflow warnings. What's the right method to avoid overflows and fix them?
Thanks in advance
1 Comment
Walter Roberson
on 21 Dec 2019
Edited: Walter Roberson
on 3 Jan 2020
Typically there are two ways to approach this:
It is not uncommon that you need to do both of those -- not uncommon that when you examine your code in detail that you find some mistake in it, but that you also find some reason why it is reasonable for the control values to need to go outside the range you have permitted.
Answers (1)
MathWorks Fixed Point Team
on 3 Jan 2020
I think it’s important to understand if these overflows are a concern in the context of the numerical behavior of your control algorithm i.e. Is the fixed point response within a reasonable tolerance compared to the floating point response?
If the answer is no, you can try two quick things:
- Increase the word length choice in the Fixed-Point Tool to check if greater precision improves the numerical behavior or
- Specify a larger safety margin that will accommodate for a larger operating range as Walter suggested (see image below)

It might help to check out these how to videos on Fixed-Point Tool:
3 Comments
See Also
Categories
Find more on Computer Vision With Simulink in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!