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, theDiagnostic Vieweropens and displays the following errors inModel Loadstage.

    Tip

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

  2. In the Simulink Editor, in theModelingtab, selectModel Settings>Model Properties, and examine the callback error.

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

    Diagnostic Viewerlists errors and warnings in stages. Each stage inDiagnostic Viewerrepresents a single event such as model load, update diagram, simulation, or build.

  4. Filter out warnings by clickingso 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 theDiagnostic Viewerto identify remaining problems.

    Note

    If an error or warning has a predefined fix, the diagnostic message pane displays aSuggested Actionssection. You can use theFixbutton 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 theSuppressbutton. You can restore the warning from that source using theRestorebutton. For example, if aCounter Free-Runningblock 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 theC Codetab, clickBuild.

    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