Main Content

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.

  1. Open the ex_detect_overflows model.

    addpath(fullfile(docroot,'toolbox','fixpoint','examples'))
    ex_detect_overflows

    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.

  2. Simulate the model.

    The Diagnostic Viewer displays two overflow warnings. The first overflow saturated and the second overflow wrapped.

  3. In the Configuration Parameters dialog box:

    • Set Diagnostics > Data Validity > Wrap on overflow to Error.

    • Set Diagnostics > Data Validity > Saturate on overflow to Warning.

  4. 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.

See Also

|