有没有办法检索未正确完成的函数的输出?
例如,一个(非全局)变量被函数正确计算但由于语法错误而无法正确保存。
最佳答案
原则上,一旦程序因错误而停止,您就无法查看函数。 (这就是为什么我经常尝试避免使用函数。)
但是,您可以通过使用 dbstop
进入 Debug模式 来实现您想要的效果。设置断点的函数:
The
dbstop
function is used to temporarily stop the execution of a program and give the user an opportunity to examine the local workspace.
特别是打字
dbstop if error
在运行代码之前在命令窗口中将使其停止在导致错误的位置并查看该函数中的变量。
要恢复正常行为,您需要 dbclear
功能。类型
dbclear if error
删除之前设置的断点,或者
dbclear all
删除所有断点。
关于matlab - 从使 matlab 崩溃的函数中检索变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33129226/