如何调试matlab代码没有gui [英] How to debug matlab code without gui

查看:401
本文介绍了如何调试matlab代码没有gui的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始使用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.

推荐答案

要使用命令行设置断点,请 dbstop 是工具(加上 dbclear 清除断点和 dbstatus 以列出它们。)

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:


  1. 停止
  2. 的M档案

  3. 子功能

  4. 对任意表达式有条件。例如,

  1. The M-file in which to stop
  2. Line number
  3. Sub-function
  4. 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

  • At any run-time error (dbstop if error)
  • At a specific error (e.g dbstop if error myFun.m:barErrorId)
  • At any warning (dbstop if warning) or specific warning
  • If NaN or Inf are encountered (dbstop if naninf)
  • 有关详细信息和好例子,请参阅 dbstop 的文档。

    See the documentation for dbstop for details and good examples.

    dbcont (或F5), dbstep (或F10), dbquit (Shift + F5), dbstep (也 dbstep在 dbstep out ), dbstack (看看你在哪里,怎么到达那里)。

    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).

    查看函数的摘要和一个列表 MathWorks调试页面中的示例和操作方法页面。

    See the summary of functions and a list of examples and how-to pages in the MathWorks page on Debugging.

    db 函数相关的是 checkcode ,在您运行它之前,将检查您的代码是否存在可能的问题。

    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 并且是语法,您不会经常需要插入 键盘 添加到您的代码中,但它始终是一个选项。

    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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆