你可以暂停MATLAB吗

你可以暂停MATLAB吗

本文介绍了你可以暂停MATLAB吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

在MATLAB中,我运行一些需要一段时间运行的代码。我想暂停代码来检查一些变量值。有没有办法可以做到这一点,而不必从头开始重新运行代码?我不想终止程序;只需暂停它。

解决方案

您可以通过两种方式停止执行并给出命令提示符:




  • 在您要停止的代码中放入键盘

  • 设置断点。



您可以使用 dbcont dbquit 。要转发,请使用 dbstep dbstack 让你看到你在哪里。还有更多命令。这些帮助页面将为您提供其他建议。



正如Dennis Jaheruddin所指出的, dbstop 有几个有用的功能值得尝试。特别是能够通过 dbstop if 语法来设置条件和全局(任何符合条件的线)断点。例如,如果错误,那么 dbstop将会在任何错误时中断调试命令提示符。他现在做的一个建议是把 dbstop if error into startup.m ,以便这个行为当您启动MATLAB时将默认。您可能需要在 userpath 文件夹中创建此文件; edit(fullfile(regexp(userpath,'^ [^;] *','match','once'),'startup.m')) >

In MATLAB, I'm running some code which takes a while to run. I'd like to pause the code to check on some variable values. Is there a way I can do this without having to re-run the code from the beginning? I don't want to terminate the program; just pause it.

解决方案

You can halt execution and give a command prompt in two ways of which I am aware:

  • Putting keyboard in your code where you want to stop.
  • Setting a breakpoint.

You can resume and stop execution with dbcont and dbquit, respectively. To step forward, use dbstep. dbstack lets you see where you are. There are many more commands. The help page for any of these will give you other suggestions.

As Dennis Jaheruddin has pointed out, dbstop also has several useful features worth trying. In particular is the ability to set conditional and global (any line meeting a criterion) breakpoints via the dbstop if syntax. For example, dbstop if error will break to a debugging command prompt on any error. One suggestion he made, which I now do, is to put dbstop if error into startup.m so that this behavior will be default when you start MATLAB. You may need to create this file in a userpath folder; edit(fullfile(regexp(userpath,'^[^;]*','match','once'),'startup.m')).

这篇关于你可以暂停MATLAB吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 15:11