| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
| On this page… |
|---|
Running the M-Lint Code Check Folder Report |
The M-Lint Code Check Report displays potential errors and problems, as well as opportunities for improvement in your code. The term "lint" is the name given to similar tools used with other programming languages such as C. M-Lint produces a message for each line of an M-file that it determines might be improved. For example, a common M-Lint message is that a variable foo in line 12 is defined but never used in the M-file.
To run the M-Lint code check folder report, follow these steps:
In the Current Folder browser, navigate to the folder that contains the M-files you want to check with M-Lint. To use the example shown in this documentation, lengthofline.m, you can change the current folder by running
cd(fullfile(matlabroot,'help','techdoc','matlab_env','examples'))
If you plan to modify the example, save the file to a folder for which you have write access, and then make that folder the current MATLAB folder. In this example, the file is saved to I:\my_matlab_files.
In the Current
Folder browser toolbar, click the Actions button
, and then select Reports > M-Lint Code Check Report.
The M-Lint code Check Report displays in the MATLAB Web browser, showing those M-files that M-Lint identified as having potential problems or opportunities for improvement.

For each message, review the suggestion and your code, click the line number to open the M-file in the Editor at that line, and make changes based on the message. Use the following general advice:
If you are not sure what a message means or what to change in the code as a result, click on the link in the M-Lint message if one is provided, as described in Checking M-File Code for Problems Using the M-Lint Code Analyzer.
If the M-Lint message does not contain a link and you are not sure what a message means or what to change in the code as a result, use the Help browser to look for related topics in the online documentation. For examples of messages and what to do about them, including specific changes to make for the example, lengthofline.m, see Making Changes Based on M-Lint Messages.
M-Lint does not provide perfect information about every situation and in some cases, you might not want to make any changes based on the M-Lint message. In the event you do not want to change the code but you also do not want to see the M-Lint message for that line in the M-Lint Report, instruct M-Lint to ignore a line by adding %#ok to the end of the line in the M-file. (You can override the %#ok by running the mlint function with the '-notok' tag.)
If there are certain messages or types of messages you do not want to see, you can set a preference so that M-Lint does not report them. Select File > Preferences > M-Lint. In Select messages to enable, clear the check box for messages you do not want to see. Review the settings for all messages to ensure you are seeing those pertinent to your file. Click OK. For more information, click the Help button in the M-Lint Preferences pane. The next time you run the report, the messages will not appear. You can use %#ok with a specific message ID so that only that type of message is suppressed—for more information, see the reference page for mlint.
After making changes, save the M-file. Consider saving the file to a different name if you made significant changes that might introduce errors. Then you can refer to the original file if needed to resolve problems with the updated file. Use Tools > Compare Against in the Editor to help you identify the changes you made to the file. For more information, see Comparing Two Text Files.
Run and debug the file(s) again to be sure you have not introduced any inadvertent errors.
If the M-Lint Code Check Report is already displayed, click Rerun This Report to update the report based on the changes you made to the file. Ensure the M-Lint messages are gone, based on the changes you made to the M-files.
For information on how to correct the potential problems presented by M-Lint, use the following resources:
If available, click the link for the extended message in the M-Lint message tooltip, as shown in the image following this list. Not all M-Lint messages have extended messages.
Look for relevant topics in the Programming Fundamentals and Programming Tips documentation.
Use the Help browser Search and Index panes to find documentation about terms presented in the M-Lint messages.
The following image shows an M-Lint tooltip with a link to an extended M-Lint message. The orange underline indicates that an extended M-Lint message will be presented in a tooltip when you hover over the word demolint in the code. (The orange highlighting indicates that an automatic fix is available.)

Other techniques to help you identify problems in and improve your M-files are in these topics:
Syntax Highlighting in the Command Window and the Editor
Examining Errors generated when you run the M-file
Finding Errors, Debugging, and Correcting M-Files, namely the Editor and debugging functions
Profiling for Improving Performance for improving performance
You can get M-Lint messages using any of the following methods. Each provides the same M-Lint messages, but in a different format:
Access the M-Lint Code Check report for an M-file from the Editor Tools menu or from the Profiler detail report.
Run the mlint function, which analyzes the specified file and displays messages in the Command Window, or mlintrpt, which runs mlint and displays the messages in the Web Browser.
Use automatic M-Lint analysis and code correction while you work on a file in the Editor—see Checking M-File Code for Problems Using the M-Lint Code Analyzer.
![]() | Using M-File Reports | Profiling for Improving Performance | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |