MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1
It might appear that there are no mismatched delimiters. However, code analysis
detects the semicolon in parentheses: data{3}(;), and interprets it as the end of a
statement. The message reports that the two statements on line 47 each have a
delimiter imbalance.

To fix the problem, in line 47, change data{3}(;) to data{3}(:). Now, the
underline no longer appears in line 47. The single change addresses the issues in
both of the messages for line 47. Because the change removed the only error in the
file, the message indicator at the top of the bar changes from red to orange,
indicating that only warnings and potential improvements remain.

After modifying the code to address all the messages, or disabling designated messages,
the message indicator becomes green. The example file with all messages addressed has
been saved as lengthofline2.m. Open the corrected example file with the command:

open(fullfile(matlabroot,'help','techdoc',...
'matlab_env', 'examples','lengthofline2.m'))

Create a Code Analyzer Message Report


You can create a report of messages for an individual file, or for all files in a folder using
one of these methods:


  • Run a report for an individual MATLAB code file:


(^1) On the Editor window, click and select Show Code Analyzer Report.
A Code Analyzer Report appears in the MATLAB Web Browser.
2 Modify your file based on the messages in the report.
(^3) Save the file.
(^4) Rerun the report to see if your changes addressed the issues noted in the
messages.



  • Run a report for all files in a folder:


(^1) On the Current Folder browser, click.
(^2) Select Reports > Code Analyzer Report.
(^3) Modify your files based on the messages in the report.
For details, see “MATLAB Code Analyzer Report” on page 24-42.
24 Coding and Productivity Tips

Free download pdf