Matlab程序调试相关函数_第1页
Matlab程序调试相关函数_第2页
Matlab程序调试相关函数_第3页
Matlab程序调试相关函数_第4页
Matlab程序调试相关函数_第5页
已阅读5页,还剩5页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、kyboard:KEYBOARD Invoke keyboard from M-file.KEYBOARD, when placed in an M-file, stops execution of the fileand gives control to the user's keyboard. The special status isindicated by a K appearing before the prompt. Variables may beexamined or changed - all MATLAB commands are valid. The keyboa

2、rdmode is terminated by executing the command RETURN (i.e. typingthe six letters R-E-T-U-R-N and pressing the return key. Controlreturns to the invoking M-file.DBQUIT can also be used to get out of keyboard mode but in this casethe invoking M-file is terminated.The keyboard mode is useful for debugg

3、ing your M-files.See also dbquit, dbstop, return, input.Reference page in Help browser doc keyboarddbquit:Quit debug mode.The DBQUIT command immediately terminates debug mode and returnscontrol to the base workspace prompt. The M-file being processedis NOT completed and no results are returned.See a

4、lso dbstop, dbcont, dbstep, dbclear, dbtype, dbstack, dbup,dbdown, and dbstatus.Reference page in Help browser doc dbquitdbstop:Set breakpoint.The DBSTOP command is used to temporarily stop the execution of an M-fileand give the user an opportunity to examine the local workspace. There areseveral fo

5、rms to this command. They are:(1 DBSTOP in MFILE at LINENO(2 DBSTOP in MFILE at LINENO(3 DBSTOP in MFILE at LINENON(4 DBSTOP in MFILE at SUBFUN(5 DBSTOP in MFILE(6 DBSTOP in MFILE at LINENO if EXPRESSION(7 DBSTOP in MFILE at LINENO if EXPRESSION(8 DBSTOP in MFILE at LINENON if EXPRESSION(9 DBSTOP in

6、 MFILE at SUBFUN if EXPRESSION(10 DBSTOP in MFILE if EXPRESSION(11 DBSTOP if error(12 DBSTOP if caught error(13 DBSTOP if warning(14 DBSTOP if naninf or DBSTOP if infnan(15 DBSTOP if error IDENTIFIER(16 DBSTOP if caught error IDENTIFIER(17 DBSTOP if warning IDENTIFIERMFILE must be the name of an M-f

7、ile or a MATLABPATH-relative partialpathname (see PARTIALPATH. LINENO is a line number within MFILE, N is aninteger specifying the Nth anonymous function on the line, and SUBFUNis the name of a subfunction within MFILE. EXPRESSION is a string containinga evaluatable conditional expression. IDENTIFIE

8、R is a MATLAB MessageIdentifier (see help for ERROR for a description of messageidentifiers. The AT and IN keywords are optional.The forms behave as follows:(1 Stops at the specified line number in MFILE.(2 Stops just after any call to the first anonymous functionin the specified line number in MFIL

9、E.(3 As (2, but just after any call to the Nth anonymous function.(4 Stops at the specified subfunction of MFILE.(5 Stops at the first executable line in MFILE.(6-10 As (1-(5, except only stops if EXPRESSION evaluates totrue. EXPRESSION is evaluated (as if by EV AL in MFILE's workspacewhen the b

10、reakpoint is encountered, and must evaluate to a scalarlogical value (true or false.(11 Causes a stop in any M-file function causing a run-time error thatwould not be detected within a TRY.CATCH block.You cannot resume M-file execution after an uncaught run-time error.(12 Causes a stop in any M-file

11、 function causing a run-time error thatwould be detected within a TRY.CATCH block. You can resume M-fileexecution after a caught run-time error.(13 Causes a stop in any M-file function causing a run-time warning.(14 Causes a stop in any M-file function where an infinite value (Infor Not-a-Number (Na

12、N is detected.(15-17 As (11-(13, except that MATLAB only stops on an error or warningwhose message identifier is IDENTIFIER. (If IDENTIFIER is the specialstring 'all', then these uses behave exactly like (11-(13.When MATLAB reaches a breakpoint, it enters debug mode. The prompt changesto a K

13、>> and, depending on the "Open M-Files when Debugging" setting in theDebug menu, the debugger window may become active. Any MATLAB command isallowed at the prompt. To resume M-file execution, use DBCONT or DBSTEP. Toexit from the debugger, use DBQUIT.dbclear:Remove breakpoint.The DBC

14、LEAR command removes the breakpoint set by a corresponding DBSTOPcommand. There are several forms to this command. They are:(1 DBCLEAR in MFILE at LINENO(2 DBCLEAR in MFILE at LINENO(3 DBCLEAR in MFILE at LINENON(4 DBCLEAR in MFILE at SUBFUN(5 DBCLEAR in MFILE(6 DBCLEAR if ERROR(7 DBCLEAR if CAUGHT

15、ERROR(8 DBCLEAR if WARNING(9 DBCLEAR if NANINF or DBCLEAR if INFNAN(10 DBCLEAR if ERROR IDENTIFIER(11 DBCLEAR if CAUGHT ERROR IDENTIFIER(12 DBCLEAR if WARNING IDENTIFIER(13 DBCLEAR ALLMFILE must be the name of an M-file or a MATLABPATH-relative partialpathname (see PARTIALPATH. LINENO is a line numb

16、er within MFILE, and SUBFUNis the name of a subfunction within MFILE. IDENTIFIER is a MATLAB MessageIdentifier (see help for ERROR for a description of messageidentifiers. The AT and IN keywords are optional.The several forms behave as follows:(1 Removes the breakpoint at line LINENO in MFILE.(2 Rem

17、oves the breakpoint in the first anonymous function at line LINENOin MFILE.(3 Removes the breakpoint in the Nth anonymous function at line LINENOin MFILE. (Use this when there is more than one anonymous functionon the same line.(4 Removes all breakpoints in the specified subfunction of MFILE.(5 Remo

18、ves all breakpoints in MFILE.(6 Clears the DBSTOP IF ERROR statement and any DBSTOP IF ERRORIDENTIFIER statements, if set.(7 Clears the DBSTOP IF CAUGHT ERROR statement, and any DBSTOP IF CAUGHTERROR IDENTIFIER statements, if set.(8 Clears the DBSTOP IF WARNING statement, and any DBSTOP IF WARNINGID

19、ENTIFIER statements, if set.(9 Clears the DBSTOP on infinities and NaNs, if set.(10 Clears the DBSTOP IF ERROR IDENTIFIER statement for the specifiedIDENTIFIER. It is an error to clear this setting on a specificidentifier if DBSTOP IF ERROR or DBSTOP IF ERROR ALL is set.(11 Clears the DBSTOP IF CAUG

20、HT ERROR IDENTIFIER statement for the specifiedIDENTIFIER. It is an error to clear this setting on a specificidentifier if DBSTOP if caught error or DBSTOP if caught ERROR allis set.(12 Clears the DBSTOP IF WARNING IDENTIFIER statement for the specifiedIDENTIFIER. It is an error to clear this settin

21、g on a specificidentifier if DBSTOP IF WARNING or DBSTOP IF WARNING ALL is set.(13 Removes all breakpoints in all M-files, as well as those mentioned in(6-(9 above.See also dbstep, dbstop, dbcont, dbtype, dbstack, dbup, dbdown, dbstatus, dbquit, error, partialpath, try, warning.Reference page in Hel

22、p browser doc dbcleardbcont:Continue execution.The DBCONT command resumes execution of an M-file following a stop inexecution caused by either a DBSTOP or DBSTEP command. Execution willcontinue until either another breakpoint is encountered, an erroroccurs, or MATLAB returns to the base workspace pr

23、ompt.See also dbquit, dbstep, dbstop, dbclear, dbtype, dbstack, dbup, dbdown, dbstatus.Reference page in Help browserdoc dbcontdbstatus :List all breakpoints.DBSTATUS, by itself, displays a list of all the breakpoints the debuggerknows about including ERROR, CAUGHT ERROR, WARNING, and NANINF.DBSTATU

24、S MFILE displays the breakpoints set for the specified M-file. MFILEmust be the name of an m-file function or a MATLABPATH relative partialpathname (see PARTIALPATH.DBSTATUS('-completenames' outputs the "complete name" of each function.A complete name includes the absolute file nam

25、e and the entire sequence offunctions that nest the function in which a breakpoint is set.S = DBSTATUS(. returns the breakpoint information in an M-by-1structure with the fields:name - function name.file - full name of the file containing breakpoint(s.line - vector of breakpoint line numbers.anonymo

26、us - integer vector, each element of which corresponds to an element of the 'line' field. Each positive element represents a breakpoint in the body of an anonymous function on that line. For example, a breakpoint in the body of the second anonymous function on the line results in the value 2

27、 in this vector. If an element is 0, the breakpoint is at the beginning of the line, i.e., not in an anonymous function. expression - cell vector of breakpoint conditional expression strings corresponding to lines in the 'line' field. cond - condition string ('error', 'caught err

28、or', 'warning', or 'naninf'. identifier - when cond is one of 'error', 'caught error', or 'warning', a cell vector of MATLAB Message Identifier strings for which the particular cond state is set. See also dbstep, dbstop, dbcont, dbclear, dbtype, dbstack, d

29、bup, dbdown, dbquit, error, partialpath, warning. Reference page in Help browser doc dbstatus dbstack: Display function call stack. The DBSTACK command displays the M-file function name and line number where the breakpoint occurred, the name and line number of the M-file caller, the caller's cal

30、ler, etc., until the top-most M-file function is reached. DBSTACK(N omits from the display the first N frames. This is useful when issuing a dbstack from within, say, an error handler. DBSTACK('-completenames' outputs the "complete name" of each function in the stack, which means t

31、he absolute file name and the entire sequence of functions that nest the function in the stack frame. Either none, one, or both of the N and '-completenames' may appear. If both appear, the order is irrelevant. ST,I = DBSTACK returns the stack trace information in an M-by-1 6 structure ST with the fields: file - the file in which the function appears; this field will be the empty string if there is no file. name - function name within the file line - functi

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论