Handle Overflows in Simulink Models
This example shows how to control the warning messages you receive when a model contains an overflow. This diagnostic control can simplify debugging models in which only one type of overflow is of interest.
Open the Model
This model contains a sine wave with an amplitude of 1.5 passed through two Data Type Conversion blocks. In the Data Type Conversion block, the Saturate on integer overflow parameter is selected. The Data Type Conversion1
block wraps when the signal is too large to fit into the output data type.
open_system('ex_detect_overflows')
Simulate Model with Original Diagnostic Settings
Simulate the model.
The Diagnostic Viewer displays two overflow warnings. The first overflow saturated and the second overflow wrapped.
Adjust Diagnostic Settings
In the Configuration Parameters dialog box:
Set Diagnostics > Data Validity > Wrap on overflow to
Error
.Set Diagnostics > Data Validity > Saturate on overflow to
Warning
.Simulate the model again.
The Diagnostic Viewer displays an error message for the overflow that wrapped, and a warning message for the overflow that saturated.