在任何运行时错误后,在Matlab中指定回调 [英] Specifying a callback in Matlab after any runtime error

查看:177
本文介绍了在任何运行时错误后,在Matlab中指定回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在Matlab发生错误时指定要运行的代码? Googling我遇到了RunTimeErrorFcn和daqcallback,但我相信这些是特定于数据采集工具箱。当我只是跳过一个错误,就像访问未分配的变量,我想要一些东西。 (我使用一个名为PsychToolbox的库来接管GPU,所以我希望能够在返回命令提示符之前清除屏幕。)

Is there a way to specify code to be run whenever an error occurs in Matlab? Googling I came across RunTimeErrorFcn and daqcallback, but I believe these are specific to the Data Acquisition Toolbox. I want something for when I just trip over a bug, like an access to an unassigned variable. (I use a library called PsychToolbox that takes over the GPU, so I want to be able to clear its screen before returning to the command prompt.)

推荐答案

一个诀窍是使用错误断点,发出以下命令:

One trick is to use Error Breakpoints by issuing the command:

dbstop if error

当启用时,会导致MATLAB进入错误点的调试模式。您可以从主工具栏上的 Debug 菜单中访问相同的功能。

which when enabled, causes MATLAB to enter debug mode at the point of error. You can access the same functionality from the Debug menu on the main toolbar.

这篇关于在任何运行时错误后,在Matlab中指定回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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