How do I suppress the message "A Code Analyzer message was once suppressed here, but the message is no longer generated"?
조회 수: 8 (최근 30일)
이전 댓글 표시
Dear all:
I have the following scenario: I want to be able to easily switch between 2 ways how a vector is calculated. I know that perhaps, it would have been more correct to have a logical variable and calculate the vector based on that variable. However, for rough testing scenarios I often keep two lines of code (e.g. a = b; a = c) and comment out the second line in the case I want to use the first approach. This, of course, generates the warning that the first calculation is redundant as it's unused. I suppress it with %#ok<ASGLU>. But then when I comment out the second assignment Matlab complains again as described in the title of the question. There seems to be no way to suppress this warning in the Matlab code analyzer preferences. And I would rather not distable the first warning about an unused assignment because it's useful. Is there a way to globally turn off the second warning only? Thanks.
댓글 수: 1
John Chilleri
2017년 1월 12일
When you right click to suppress, it sometimes offers "suppress in this file" which might help.
답변 (2개)
Jyotish Robin
2017년 1월 18일
You can selectively enable or disable specific warning messages, as long as they have been given a message identifier, with the "warning" function using the 'state' and 'message_id' input arguments.
To suppress specific warning messages, you must first find the warning identifier. Each warning message has a unique identifier. After you obtain the identifier, use this information to disable or enable the warning associated with that identifier.
You can refer the following links for more insight:
- http://www.mathworks.com/help/matlab/matlab_prog/suppress-warnings.html#zmw57dd0e54607
- http://www.mathworks.com/help/matlab/ref/warning.html
Hope it helps!
댓글 수: 0
Christopher Rock
2021년 9월 29일
You can use %#ok<%MSNU> to ignore all Code Analyzer highlighting for unused flags within the current file.
참고 항목
카테고리
Help Center 및 File Exchange에서 Whos에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!