问题描述
我最近开始使用matlab没有GUI通过启动matlab与-nodesktop选项,它是相当快的。
I have recently started using MATLAB without GUI by starting matlab with -nodesktop option and it is considerably faster.
但是目前我没有办法在非gui模式下调试.m脚本。我必须打开默认的matlab编辑器每次我必须debug.Has任何人想出了一种方法来做吗?
提前感谢
However presently I have no way to debug a .m script in non gui mode. I have to open the default matlab editor every time I have to debug.Has anyone figured out a way to do it?Thanks in advance
我使用的是Ubuntu Linux,万一有帮助。
I am using Ubuntu Linux, in case that helps.
推荐答案
要使用命令行设置断点,请是工具(加上清除断点和以列出它们。)
To set breakpoints with the command line, dbstop
is the tool (plus dbclear
to clear breakpoints and dbstatus
to list them).
目前有 dbstop
的17种不同表单允许您指定以下各种组合:
There are presently 17 different forms to dbstop
, which allow you to specify various combinations of:
- 停止 的M档案
- 子功能
-
对任意表达式有条件。例如,
- The M-file in which to stop
- Line number
- Sub-function
Conditional to an arbitrary expression. For example,
dbstop in myFun.m at 224 if ~exist('x','var')
dbstop if error
) dbstop,如果错误myFun.m:barErrorId
) dbstop如果警告
)或特定警告 NaN
遇到 Inf
( dbstop if naninf
)dbstop if error
)dbstop if error myFun.m:barErrorId
)dbstop if warning
) or specific warningNaN
or Inf
are encountered (dbstop if naninf
)有关详细信息和好例子,请参阅 dbstop
的文档。
See the documentation for dbstop
for details and good examples.
(或F5), dbstep
(或F10), dbquit
(Shift + F5), dbstep
(也 dbstep在
, dbstep out
),(看看你在哪里,怎么到达那里)。
Also get used to dbcont
(or F5), dbstep
(or F10), dbquit
(Shift+F5), dbstep
(also dbstep in
, dbstep out
), dbstack
(to see where you are and how you got there). The keyboard shortcuts may be different outside of Windows.
使用更少,但仍然非常有用的是 dbup
和 dbdown
,它允许您切换工作区上下文(内存堆栈)。
Far less used, but still very useful are dbup
and dbdown
, which allow you to switch workspace context (memory stacks).
查看函数的摘要和一个列表页面中的示例和操作方法页面。
See the summary of functions and a list of examples and how-to pages in the MathWorks page on Debugging.
与 db
函数相关的是,在您运行它之前,将检查您的代码是否存在可能的问题。
Related to the "db
" functions is checkcode
, which will check your code for possible problems before you even run it. This is a nice substitute for the red squiggly underlines that you would get in the MATLAB Editor.
一旦你得到了 dbstop $的挂起句柄,你就可以在MATLAB编辑器中得到。 c $ c>并且是语法,您不会经常需要插入添加到您的代码中,但它始终是一个选项。
Once you get a hang of dbstop
and it's syntax, you won't often need to insert a keyboard
into your code, but it's always an option.
这篇关于如何调试matlab代码没有gui的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!