
M-Lint Code Check Report
Message — Code (Original Line Numbers)
Explanation and Updated Code (New
Line Numbers)
49: Terminate statement with semicolon
to suppress output (in functions).
Adding a semicolon to the end of a statement
suppresses output and is a common practice.
M-Lint alerts you to lines that produce output
but lack the terminating semicolon. If you want
to view output from this line, do not add the
semicolon. You can instruct M-Lint to ignore
all messages on this line so that the me ssage s
on it will not appear by adding
%#ok to the end
of the line. However, because there is currently
another message on the line, do not add
%#ok
until you have addressed the other message.
Alternatively, you can add
%#ok with the
messageIDforthespecificmessageyou
want to suppress. To determine the message
ID, run
mlint('lengthofline.m', '-id'),
which indicates the ID is
NOPRT—for more
information , see the
mlint function reference
page.
For this example, assume y ou want to display
the output and suppress the M-Lint message.
To do so, add
%#ok<NOPRT> to the end of the
line.
Note that there is a similar message for
M-file scripts. This is so you can suppress the
message for M-files that are cell-mode scripts,
because they are often intended as demos and
the display of output is intentional.
49: Use of brackets [] is unnecessary.
Use parentheses to group, if needed.
—————————————————
49 len(nl) =
sum([sqrt(dot(temp',temp'))])
For more information about the use of brackets
and parentheses, see the Special Characters
reference page. In this example, remove
the brackets because they are not needed.
They add processing time because MATLAB
concatenates unnecessarily. Change line 52 to
len(nl) = sum(sqrt(dot(temp',temp')))
%#ok
7-25
Comentários a estes Manuais