在matlab中一般调用函数时如何使用try和catch打印出未知错误信息

how to use try and catch to print out the unknown error message when calling a function in general in matlab

这是代码

try
    ** = myfunction( ~ );
catch e
    % how shall I do to print out the unknown message ?
end

我在项目中遇到过这个问题。我已经修复了错误。但我还是有些迷茫,没有答案。所以我post在这里。

您必须决定如何处理捕获中的错误。你想简单地打印出错误消息并继续吗?如果是:

try
    ** = myfunction( ~ );

catch e
    fprintf(1,'ERROR: %s\n', e.message);

end