17-3 ��������������������������?

HOCDƥiΩUؤPxA\iCpUG

yk\
dbstop at line# in filename ]w_I]Break Points^
]line# N渹Afilename NɮצW١^
dbclear at line# in filename M_I
]line#N渹Afilename NɮצW١^
dbstop if warning YJUCpAhȰ{G
  • ĵi]Warning^
  • ~]Error^
  • Dƭ/Laj]NaN/Inf^
dbstop if error
dbstop if naninf
dbstop if infnan
dbcont qȰA~
dbstack CXƩIsL{|
dbstatus filename CXYɮתҦ_I
]filename NɮצW١^
dbstep n n CO
dbtype filename CXɮפe]]tCCs^
]filename NɮצW١^
dbdown VUiJu@Ŷ
dbup VWiJIsݪu@Ŷ
dbquit

bWzOA̭nONO dbstopAڭ̥iHQγoӫOӫw{X_I]Break Points^Aϱo MATLAB ib_IeAHڭ̯ˬdUӧܼƪȡCdbstop @榡άiCpUG

O榡
dbstop in filename at line# YɮתY
]filename NɮצW١Aline#N渹^
dbstop in filename at subfunction Yɮת
]filename NɮצW١^
dbstop in filename
]filename NɮצW١^
dbstop if error YX{~AhȰ{AðdboͿ~u@Ŷ
dbstop if warning YX{ĵiAhȰ{Aðdboĵiu@Ŷ
dbstop if naninf YX{ nan infAhȰ{Aðdbo nan infu@Ŷ
dbstop if infnan ]PW^

bWAinBat M if iHٲAҥHudbstop in testfunc at 15viH²gudbstop testfunc 15vC

@{AMATLAB NiJҿת uҦv]Debugging Mode^AOCW|X{k>>ܸANɥiHLJCpGzϥΪxO PC MACAPɤ]|X{ M ɮװ]M-file Debugger^Ai˵{XC M ɮװӸ`AN|bU@`ԲӤСA`hHЫOCODC

iJҦAڭ̥iˬdܼƪȡA]iHLOΤZ]Scripts^CˬdAiĨʧ@iC|pUG

O榡
dbcont ~{
dbstep n n C{X
dbtype filename CX{X
]filename N{ɮצW١^
dbdown VUܥt@Ӥu@Ŷ
dbup VWܥt@Ӥu@Ŷ
dbstack CXƩIsL{|
dbquit

bWA̱`Ψ쪺OO dbstepAiHڭ̤@@CΦhC{XAάOiJθX@ӫO{XA榡iC|pUG

O榡
dbstep U@C{X
dbstep n U n C{X
dbstep in iJU@CO{X
dbstep out XثeO{X

LUO榡TwAohTAi MATLAB uW䴩oC

t~Adbclear dbstatus iΩ@ҦΰҦCdbclear Ω_IAM dbstop \nۤϡAdbclear ϥή榡iѨ`Ĥ@Ӫ]Y dbstop ϥή榡^AuݱNҦ dbstop אּ dbclear YiC

~AYnMҦ_IAi dbclear allC

dbstatus iCXҦ_IA榡pUG

O榡
dbstatus CXҦ_I
dbstatus filename CXb@ɮפ_I
]filename N{ɮצW١^
s = dbstatus(K) N_ITǦ^ܼ s

HUNHҨӻoǰOBΡC

]ڭ̭np@Vq˼ƩMAiϥΦW٬ recipsum.m ơApUG

>> type recipsum function out = recipsum(x) recip = reciproc(x); out = sum(recip); function output = reciproc(input) output = 1./x;

ƥ]t@~AɧY|X{G

>> recipsum([1 2 3]) Undefined function or variable 'x'. Error in recipsum>reciproc (line 7) output = 1./x; Error in recipsum (line 3) recip = reciproc(x);

Hint
dҪ~TAOH MATLAB 8.5 DCP MATLABAiಣͤP~TAOjPpC

~TOѦ reciproc Ҳ͡CFKA~ToͮɡAڭ̥iH MATLAB MdbͿ~TơAҨϥΪOpUG

>> dbstop if error

i dbstop ӽT{ҫإߪ_G

>> dbstatus Stop if error.

ɥiAIsơG

>> recipsum([1 2 3])

MATLAB o|b~oͪ{XAñNVܩ MATLAB ]]O MATLAB s边^ApUG

ɧڭ̥ibOϥ dbstack MATLAB ҦbơG

k>> dbstack > In recipsum>reciproc (line 7) In recipsum (line 3)

i dbtype ܵ{XG

k>> dbtype recipsum 1 function out = recipsum(x) 2 3 recip = reciproc(x); 4 out = sum(recip); 5 6 function output = reciproc(input) 7 output = 1./x;

ܩaAb reciproc Ƥܼ x åwqA]ڭ̥ibN x 令 input Axsɮש recipsum1.mANFu@CɦAiƩIsANio쥿TסG

k>> dbquit % }Ҧ >> recipsum1([1 2 3]) ans = 1.8333

Hint
@bisɮתʧ@AMATLAB N|XҦAdzƦA氣᪺{XC

WҪ~O۷өApGJ~ANݦb{XAbOCv@ˬdiXDܼơAXDҦbAAi{XקG

~A{Ȱ@ӨƮɡAڭ̤]iHϥ dbup dbdown Ӹ줣Pu@ŶAHK˵UܼơC

]b recipsum.m ~wץAץ᪺ɮ׬O recipsum1.mAڭ٬OiJLDAҦpG

>> recipsum1([2 0 2]) ans = Inf

ɶǦ^׬ Inf]Laj^AoäOڭ̹wס]]ڭ̨èSwϥΪ̷|Jt 0 Vq^Cd~ҦbAڭ̳]ߥt@Ӥ_AæAIsơG

>> dbstop if naninf >> recipsum1([2 0 2]) NaN/Inf breakpoint hit for recipsum1>reciproc on line 7. 7 output = 1./input;

ܩaAbp 0 ˼ƮɡAX{F InfCڭ̰]bJ 0 ɡA˼ƤpAh{XiץpUG

k>> dbquit % }Ҧ >> type recipsum2 function out = recipsum(x) recip = reciproc(x); out = sum(recip); function output = reciproc(input) input(find(input==0)) = []; % Eliminate "0" elements output = 1./input;

ɦAIsơANiHͧڭ̹wGG

>> recipsum2([2 0 2]) ans = 1

Hint
bijqcƭȹBɡA Nan Inf ͡AϥΡudbstop if naninf v̾AXI


MATLAB{]pGJg