Main Content

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.

    Diagnostic Viewer displaying information and error messages related to loading of model vdp_callback. These diagnostic messages are displayed: 1. Model opened successfully. 2. Error evaluating PostLoadFcn callback of block diagram vdp_callback.

    Tip

    To open the Diagnostic Viewer window, in the Debug tab, click Diagnostics or click the view errors or warnings link displayed at the bottom of the Simulink® Editor window.

  2. In the Simulink Editor, in the Modeling tab, select Model Settings > Model Properties, and examine the callback error.

    Model Properties window of model vdp_callback displaying the PostLoadFnc callback.

  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.

    Diagnostic Viewer displaying stages in the drop-down menu.

  4. To address errors first, click the button to hide warning messages and the button to hide information messages to filter out warning and information messages.

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

    Block diagram of the model vdp_callback with the source of error highlighted in red and yellow.

  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, in the C Code tab, click Build.

    If there is a failure during code generation, the build summary in the Diagnostic Viewer includes Suggested Actions and an Open button next to each action to help to identify and fix the source of errors causing the build failure.

    Diagnostic Viewer displaying the build summary of the model vdp_callback with suggested actions for the errors causing the build failure.

See Also

Tools

Topics