Systematic Diagnosis of Errors and Warnings

This example shows how to use the Diagnostic Viewer to identify and locate simulation errors and warnings systematically.

  1. Open your model.

    If your model contains errors related to callback functions, the Diagnostic Viewer opens and displays the following errors in Model Load stage.

    Tip

    To open the Diagnostic Viewer window, click View > Diagnostic Viewer or click the view errors or warnings link displayed at the bottom of the Simulink® Editor window.

  2. In the Simulink Editor, click File > Model Properties > Model Properties, and examine the callback error.

  3. After fixing any callback errors, simulate the model to diagnose simulation errors and warnings.

    Diagnostic Viewer lists errors and warnings in stages. Each stage in Diagnostic Viewer represents a single event such as model load, update diagram, simulation, or build.

  4. Filter out warnings by clicking so that you can address errors first.

  5. To locate the source of the error, click the hyperlink in the message. The model in the source is highlighted. If a block has multiple ports, you can hover over each port to see the port number.

  6. After fixing all errors, simulate your model again and view the Diagnostic Viewer to identify remaining problems.

    Note

    If an error or warning has a predefined fix, the diagnostic message pane displays a Suggested Actions section. You can use the Fix button provided in this section to rectify the related error or warning. For more information see, Suggested Actions.

  7. If an object in your model generates a warning that you do not want to be notified of, sometimes, you can suppress the warning from the specified source using the Suppress button. You can restore the warning from that source using the Restore button. For example, if a Counter Free-Running block generates an overflow warning that is intentional in your design, you can suppress only overflow warnings from this particular block, without sacrificing notification of other overflows in your model.

  8. To generate code for your model, click Code > C/C++ Code > Build Model.

    Note

    If there is a failure during code generation, Diagnostic Viewer provides hyperlinks for easy navigation to the source of the error or warning message.

Related Topics