Matlab程序调试相关函数.docx

上传人:b****3 文档编号:4115200 上传时间:2022-11-28 格式:DOCX 页数:6 大小:17.08KB
下载 相关 举报
Matlab程序调试相关函数.docx_第1页
第1页 / 共6页
Matlab程序调试相关函数.docx_第2页
第2页 / 共6页
Matlab程序调试相关函数.docx_第3页
第3页 / 共6页
Matlab程序调试相关函数.docx_第4页
第4页 / 共6页
Matlab程序调试相关函数.docx_第5页
第5页 / 共6页
点击查看更多>>
下载资源
资源描述

Matlab程序调试相关函数.docx

《Matlab程序调试相关函数.docx》由会员分享,可在线阅读,更多相关《Matlab程序调试相关函数.docx(6页珍藏版)》请在冰豆网上搜索。

Matlab程序调试相关函数.docx

Matlab程序调试相关函数

kyboard:

KEYBOARDInvokekeyboardfromM-file.

KEYBOARD,whenplacedinanM-file,stopsexecutionofthefile

andgivescontroltotheuser'skeyboard.Thespecialstatusis

indicatedbyaKappearingbeforetheprompt.Variablesmaybe

examinedorchanged-allMATLABcommandsarevalid.Thekeyboard

modeisterminatedbyexecutingthecommandRETURN(i.e.typing

thesixlettersR-E-T-U-R-Nandpressingthereturnkey.Control

returnstotheinvokingM-file.

DBQUITcanalsobeusedtogetoutofkeyboardmodebutinthiscase

theinvokingM-fileisterminated.

ThekeyboardmodeisusefulfordebuggingyourM-files.

Seealsodbquit,dbstop,return,input.

ReferencepageinHelpbrowserdockeyboard

dbquit:

Quitdebugmode.

TheDBQUITcommandimmediatelyterminatesdebugmodeandreturns

controltothebaseworkspaceprompt.TheM-filebeingprocessed

isNOTcompletedandnoresultsarereturned.

Seealsodbstop,dbcont,dbstep,dbclear,dbtype,dbstack,dbup,

dbdown,anddbstatus.

ReferencepageinHelpbrowserdocdbquit

dbstop:

Setbreakpoint.

TheDBSTOPcommandisusedtotemporarilystoptheexecutionofanM-file

andgivetheuseranopportunitytoexaminethelocalworkspace.Thereare

severalformstothiscommand.Theyare:

(1DBSTOPinMFILEatLINENO

(2DBSTOPinMFILEatLINENO@

(3DBSTOPinMFILEatLINENO@N

(4DBSTOPinMFILEatSUBFUN

(5DBSTOPinMFILE

(6DBSTOPinMFILEatLINENOifEXPRESSION

(7DBSTOPinMFILEatLINENO@ifEXPRESSION

(8DBSTOPinMFILEatLINENO@NifEXPRESSION

(9DBSTOPinMFILEatSUBFUNifEXPRESSION

(10DBSTOPinMFILEifEXPRESSION

(11DBSTOPiferror

(12DBSTOPifcaughterror

(13DBSTOPifwarning

(14DBSTOPifnaninforDBSTOPifinfnan

(15DBSTOPiferrorIDENTIFIER

(16DBSTOPifcaughterrorIDENTIFIER

(17DBSTOPifwarningIDENTIFIER

MFILEmustbethenameofanM-fileoraMATLABPATH-relativepartial

pathname(seePARTIALPATH.LINENOisalinenumberwithinMFILE,Nisan

integerspecifyingtheNthanonymousfunctionontheline,andSUBFUN

isthenameofasubfunctionwithinMFILE.EXPRESSIONisastringcontaining

aevaluatableconditionalexpression.IDENTIFIERisaMATLABMessage

Identifier(seehelpforERRORforadescriptionofmessage

identifiers.TheATandINkeywordsareoptional.

Theformsbehaveasfollows:

(1StopsatthespecifiedlinenumberinMFILE.

(2Stopsjustafteranycalltothefirstanonymousfunction

inthespecifiedlinenumberinMFILE.

(3As(2,butjustafteranycalltotheNthanonymousfunction.

(4StopsatthespecifiedsubfunctionofMFILE.

(5StopsatthefirstexecutablelineinMFILE.

(6-10As(1-(5,exceptonlystopsifEXPRESSIONevaluatesto

true.EXPRESSIONisevaluated(asifbyEVALinMFILE'sworkspace

whenthebreakpointisencountered,andmustevaluatetoascalar

logicalvalue(trueorfalse.

(11CausesastopinanyM-filefunctioncausingarun-timeerrorthat

wouldnotbedetectedwithinaTRY...CATCHblock.

YoucannotresumeM-fileexecutionafteranuncaughtrun-timeerror.

(12CausesastopinanyM-filefunctioncausingarun-timeerrorthat

wouldbedetectedwithinaTRY...CATCHblock.YoucanresumeM-file

executionafteracaughtrun-timeerror.

(13CausesastopinanyM-filefunctioncausingarun-timewarning.

(14CausesastopinanyM-filefunctionwhereaninfinitevalue(Inf

orNot-a-Number(NaNisdetected.

(15-17As(11-(13,exceptthatMATLABonlystopsonanerrororwarning

whosemessageidentifierisIDENTIFIER.(IfIDENTIFIERisthespecial

string'all',thentheseusesbehaveexactlylike(11-(13.

WhenMATLABreachesabreakpoint,itentersdebugmode.Thepromptchanges

toaK>>and,dependingonthe"OpenM-FileswhenDebugging"settinginthe

Debugmenu,thedebuggerwindowmaybecomeactive.AnyMATLABcommandis

allowedattheprompt.ToresumeM-fileexecution,useDBCONTorDBSTEP.To

exitfromthedebugger,useDBQUIT.

dbclear:

Removebreakpoint.

TheDBCLEARcommandremovesthebreakpointsetbyacorrespondingDBSTOP

command.Thereareseveralformstothiscommand.Theyare:

(1DBCLEARinMFILEatLINENO

(2DBCLEARinMFILEatLINENO@

(3DBCLEARinMFILEatLINENO@N

(4DBCLEARinMFILEatSUBFUN

(5DBCLEARinMFILE

(6DBCLEARifERROR

(7DBCLEARifCAUGHTERROR

(8DBCLEARifWARNING

(9DBCLEARifNANINForDBCLEARifINFNAN

(10DBCLEARifERRORIDENTIFIER

(11DBCLEARifCAUGHTERRORIDENTIFIER

(12DBCLEARifWARNINGIDENTIFIER

(13DBCLEARALL

MFILEmustbethenameofanM-fileoraMATLABPATH-relativepartial

pathname(seePARTIALPATH.LINENOisalinenumberwithinMFILE,andSUBFUN

isthenameofasubfunctionwithinMFILE.IDENTIFIERisaMATLABMessage

Identifier(seehelpforERRORforadescriptionofmessage

identifiers.TheATandINkeywordsareoptional.

Theseveralformsbehaveasfollows:

(1RemovesthebreakpointatlineLINENOinMFILE.

(2RemovesthebreakpointinthefirstanonymousfunctionatlineLINENO

inMFILE.

(3RemovesthebreakpointintheNthanonymousfunctionatlineLINENO

inMFILE.(Usethiswhenthereismorethanoneanonymousfunction

onthesameline.

(4RemovesallbreakpointsinthespecifiedsubfunctionofMFILE.

(5RemovesallbreakpointsinMFILE.

(6ClearstheDBSTOPIFERRORstatementandanyDBSTOPIFERROR

IDENTIFIERstatements,ifset.

(7ClearstheDBSTOPIFCAUGHTERRORstatement,andanyDBSTOPIFCAUGHT

ERRORIDENTIFIERstatements,ifset.

(8ClearstheDBSTOPIFWARNINGstatement,andanyDBSTOPIFWARNING

IDENTIFIERstatements,ifset.

(9ClearstheDBSTOPoninfinitiesandNaNs,ifset.

(10ClearstheDBSTOPIFERRORIDENTIFIERstatementforthespecified

IDENTIFIER.Itisanerrortoclearthissettingonaspecific

identifierifDBSTOPIFERRORorDBSTOPIFERRORALLisset.

(11ClearstheDBSTOPIFCAUGHTERRORIDENTIFIERstatementforthespecified

IDENTIFIER.Itisanerrortoclearthissettingonaspecific

identifierifDBSTOPifcaughterrororDBSTOPifcaughtERRORall

isset.

(12ClearstheDBSTOPIFWARNINGIDENTIFIERstatementforthespecified

IDENTIFIER.Itisanerrortoclearthissettingonaspecific

identifierifDBSTOPIFWARNINGorDBSTOPIFWARNINGALLisset.

(13RemovesallbreakpointsinallM-files,aswellasthosementionedin

(6-(9above.

Seealsodbstep,dbstop,dbcont,dbtype,dbstack,dbup,dbdown,dbstatus,dbquit,error,partialpath,try,warning.

ReferencepageinHelpbrowserdocdbclear

dbcont:

Continueexecution.

TheDBCONTcommandresumesexecutionofanM-filefollowingastopin

executioncausedbyeitheraDBSTOPorDBSTEPcommand.Executionwill

continueuntileitheranotherbreakpointisencountered,anerror

occurs,orMATLABreturnstothebaseworkspaceprompt.

Seealsodbquit,dbstep,dbstop,dbclear,dbtype,dbstack,dbup,dbdown,dbstatus.

ReferencepageinHelpbrowser

docdbcont

dbstatus:

Listallbreakpoints.

DBSTATUS,byitself,displaysalistofallthebreakpointsthedebugger

knowsaboutincludingERROR,CAUGHTERROR,WARNING,andNANINF.

DBSTATUSMFILEdisplaysthebreakpointssetforthespecifiedM-file.MFILE

mustbethenameofanm-filefunctionoraMATLABPATHrelativepartial

pathname(seePARTIALPATH.

DBSTATUS('-completenames'outputsthe"completename"ofeachfunction.

Acompletenameincludestheabsolutefilenameandtheentiresequenceof

functionsthatnestthefunctioninwhichabreakpointisset.

S=DBSTATUS(...returnsthebreakpointinformationinanM-by-1

structurewiththefields:

name--functionname.

file--fullnameofthefilecontainingbreakpoint(s.

line--vectorofbreakpointlinenumbers.

anonymous--integervector,eachelementofwhichcorrespondstoanelementofthe'line'field.Eachpositiveelementrepresentsabreakpointinthebodyofananonymousfunctiononthatline.Forexample,abreakpointinthebodyofthesecondanonymousfunctiononthelineresultsinthevalue2inthisvector.Ifanelementis0,thebreakpointisatthebeginningoftheline,i.e.,notinananonymousfunction.expression--cellvectorofbreakpointconditionalexpressionstringscorrespondingtolinesinthe'line'field.cond--conditionstring('error','caughterror','warning',or'naninf'.identifier--whencondisoneof'error','caughterror',or'warning',acellvectorofMATLABMessageIdentifierstringsforwhichtheparticularcondstateisset.Seealsodbstep,dbstop,dbcont,dbclear,dbtype,dbstack,dbup,dbdown,dbquit,error,partialpath,warning.ReferencepageinHelpbrowserdocdbstatusdbstack:

Displayfunctioncallstack.TheDBSTACKcommanddisplaystheM-filefunctionnameandlinenumberwherethebreakpointoccurred,thenameandlinenumberoftheM-filecaller,thecaller'scaller,etc.,untilthetop-mostM-filefunctionisreached.DBSTACK(NomitsfromthedisplaythefirstNframes.Thisisusefulwhenissuingadbstackfromwithin,say,anerrorhandler.DBSTACK('-completenames'outputsthe"completename"ofeachfunctioninthestack,whichmeanstheabsolutefilenameandtheentiresequenceoffunctionsthatnestthefunctioninthestackframe.Eithernone,one,orbothoftheNand'-completenames'mayappear.Ifbothappear,theorderisirrelevant.[ST,I]=DBSTACKreturnsthestacktraceinformationinanM-by-16

structureSTwiththefields:

file--thefileinwhichthefunctionappears;thisfieldwillbetheemptystringifthereisnofile.name--functionnamewithinthefileline--functionlinenumberThecurrentworkspaceindexisreturnedinI.IfyousteppasttheendofanM-file,thenDBSTACKreturnsanegativelinenumbervaluetoidentifythatspecialcase.Forexample,ifthelastlinetobeexecutedisline15,thentheDBSTACKlinenumberis15beforeyouexecutethatlineand-15afterwards.Seealso

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 小学教育 > 语文

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1