Main Content

Check Code with the Code Analyzer

The code analyzer checks your code for problems and recommends modifications. You can use the code analyzer to check your code interactively in the MATLAB® Editor while you work.

To verify that continuous code checking is enabled:

  1. In MATLAB, select the Home tab and then click Preferences.

  2. In the Preferences dialog box, select Code Analyzer.

  3. In the Code Analyzer Preferences pane, verify that Enable integrated warning and error messages is selected.

The code analyzer provides an indicator in the top right of the editor window. If the indicator is green, the analyzer did not detect code generation issues.

Code analyzer window, showing green indicator

If the indicator is red, the analyzer has detected errors in your code. If it is orange, it has detected warning. When the indicator is red or orange, a red or orange marker appears to the right of the code where the error occurs. Place your pointer over the marker for information about the error. Click the underlined text in the error message for a more detailed explanation and suggested actions to fix the error.

Code analyzer window, showing red indicator and hyperlinks to error locations

Before generating code from your MATLAB code, you must fix the errors detected by the code analyzer.