如何在Matlab中抛出异常?

Aar*_*ndt 4 matlab exception

我正在写一些代码,现在我正在编写一些函数,但我还没写它们.我只是制作了一个空无一物的功能.我想做的是在函数运行时抛出异常,以防止我忘记编写函数.

Pur*_*uit 6

最简单的方法是:

error('Some useful error message.')
Run Code Online (Sandbox Code Playgroud)

Matlab更高兴的是你为你分配一个标识错误信息,如下所示:

error('toolsetname:other_identifying_information','Some useful error message here.')
Run Code Online (Sandbox Code Playgroud)

使用一些错误处理例程报告识别信息,例如,尝试lasterror在每个上述调用之后运行.