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 theHometab and then clickPreferences.

  2. In thePreferencesdialog box, selectCode Analyzer.

  3. In theCode Analyzer Preferencespane, verify thatEnable integrated warning and error messages被选中。

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.

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.

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