Check Code for Errors and Warnings
MATLAB Code Analyzer can automatically check your code for coding problems.
Automatically Check Code in the Editor — Code Analyzer
You can view warning and error messages about your code, and modify your file based on
the messages. The messages update automatically and continuously so you can see if your
changes addressed the issues noted in the messages. Some messages offer additional
information, automatic code correction, or both.
Enable Continuous Code Checking
To enable continuous code checking in a MATLAB code file in the Editor:
1
On the Home tab, in the Environment section, click Preferences.
(^2) Select MATLAB > Code Analyzer, and then select the Enable integrated warning
and error messages check box.
(^3) Set the Underlining option to Underline warnings and errors, and then click
OK.
NoteChanging the continuous code checking preferences is not supported in MATLAB
Online. Continuous code checking is always enabled.
Use Continuous Code Checking
You can use continuous code checking in MATLAB code files in the Editor:
(^1) Open a MATLAB code file in the Editor. This example uses the sample file
lengthofline.m that ships with the MATLAB software:
a Open the example file:
open(fullfile(matlabroot,'help','techdoc','matlab_env',...
'examples','lengthofline.m'))
b Save the example file to a folder to which you have write access. For the
example, lengthofline.m is saved to C:\my_MATLAB_files.
24 Coding and Productivity Tips