Installation guide
Finding Errors, Debugging , and Correcting M-Files
Technique or
To ol Description For More Information
Error Messages
When you run an M-file with a syntax error,
MATLAB will most likely detect it and display
an error mes sag e in the Comm and Window
describing the e rror and showing its line number
in the M-file. Click the underlined portion of the
error m essage, or position the cursor within the
message and press Ctrl+Enter. The offending
M-file opens in the Editor/Debugger, scrolle d to
thelinecontainingtheerror.
To check for syntax errors in an M -file without
running the M-file, use the
pcode function.
None
M-Lint
Use the M-Lint code analyzer to help you verify
the integrity of your code and learn about
potential improvements. Access M -Lint messages
automatically while you w ork in a file in the
Editor/Debugger, or run an M-Lint report for an
existing file.
To evaluate the McCabe complexity (also known
as the cyclomatic complexity) of an M-File, use
the
mlint function with the -cyc option.
“M-Lint Code Analyzer”
on page 6-87 and the
reference page for the
mlint function
Editor/
Debugger
Graphical
Debugger
and MATLAB
Debugging
Functions
The MATLAB Editor/Debugger graphical
debugger and MATLAB debugging functions are
useful for correcting run-time problems because
you can access function workspaces and examine
or change the value s they contain. You can set
and clear breakpoints, indicators that temporarily
haltexecutioninanM-file. Whilestoppedata
breakpoint, you can change workspace contexts,
view the function call stack, and execute the lines
in an M- file one by one.
“Debugging Process and
Features” on page 6-103
6-85