
Debugging Process a nd Features
Setting Breakpo
ints
Set breakpoints
topauseexecutionoftheM-filesoyoucanexaminevalues
where you think t
he problem might be. You can set breakpoints in the
Editor/Debugge
r, using functions in the Command Window, or both.
There are three
basic types of breakpoints you can set in M-files:
• Astandardbrea
kpoint, which stops at a specified line in an M-file. Fo r
details, see “S
etting Standard Breakpoints” on page 6-108.
• Aconditionalb
reakpoint, which stops at a specified line in an M-file only
under specifie
d conditions. For details, see “Con ditional Breakpoints” on
page 6-126.
• A n error b reak
point that stops in any M-file when it produces the specified
type of warnin
g, error, or
NaN or infinite value. For details, see “Error
Breakpoints”
on page 6-129.
You can disab
le standard and conditional breakpoints so that MATLAB
temporarily
ignores them, or you can remove them. For de tails, see “Di sabling
and Clearing
Breakpoints” on page 6-119. Breakpoints are not maintained
after you exi
t the MATLAB session.
You can only s
et valid standard and conditional breakpoints at executable
lines in sav
ed files that are in the current directory or in directories on the
search path
. When you add o r remove a breakpoint in a file that is not in a
directory o
n the search path or in the current directory, a dialog box appears,
presentin
g you with options that allow you to add or remov e the b reakpoint.
You can eit
her change the current directory to the directory containing the
file, or yo
u can add the directory containing the file to the search path.
Do not set a
breakpoint a t a
for statement if you want to e xamine values at
incremen
ts in the loop. For example, in
forn=1:10
m = n+1;
end
MATLAB exe
cutes the
for statement only once, which is efficient. Therefore,
when you s
et a breakpoint at the
for statement and step through the file, you
6-107
Commentaires sur ces manuels