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 window displaying information and error messages to load model vdp_callback. These errors are displayed: 1. Error evaluating PostLoadFcn callback of block diagram vdp_callback. 2. Callback string is error("A new block named 'abc' cannot be added".


    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 window showing diagnostics for various stages.

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

  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.

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

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


    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, Diagnostic Viewer provides hyperlinks for easy navigation to the source of the error or warning message.

    Diagnostic Viewer window displaying the build summary of the model vdp_callback. The build summary displays suggested actions and a hyperlink with each action to open and fix the source of error causing the build failure.

Related Topics