Is there a way to disable a specific mlint warning in an entire file?

Hello all,
Please tell me if there is a way to disable a specific mlint warning in an entire file. For example, I would like to use a lot in a certain script the str2num function. The str2double function is not a viable solution. I would like to have one place (eg. beginning of the file) in which to put a variant of the “%#ok<ST2NM>” comment and this would apply to the entire file. My main concern is that I would like to have this warning enabled in all the other scripts in this script suite that I am developing except this one script.
Thank you, Adrian

 Accepted Answer

Yes.
When you right click on the section underlined There should be a contect menu that appears. The second option should be "Suppress this warning ->". Navigate to the arrow and a subcontext menu will appear. Select "In this File".
Alternatively you can manually add a * to the suppression flag. For str2num it would look like this:
str2num('pi'); %#ok<*ST2NM>

5 Comments

Hello, I've tried your sugesstions. The one with a subcontext menu does not work becaue I do not have such a menu. The %#ok<*ST2NM> does not work; I guess is not recognized by m-lint. Another piece of information that could be useful: beacuse of compatibility issues I am forced towork with Matlab R2006b. Thank you for the answer!
Ahh, it looks like you'll have to upgrade to at least R2008b if you would like this functionality.
How do you find out the warning id, which is what I assume ST2NM is? ... because Matlab being Matlab it's only got a passing resemblance to the function name and nothing that can be directly correlated.
Right-click on the underlined section of code and select the option to suppress a specific Code Analyzer message on that line, in that file, or in all files. That will automatically add the appropriate identifier.

Sign in to comment.

More Answers (0)

Categories

Products

Asked:

on 8 Aug 2012

Commented:

on 29 Nov 2017

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!