How to use try/catch from the MATLAB engine API
5 次查看(过去 30 天)
显示 更早的评论
I'm trying to design a generic function from the MATLAB C Engine API that allows executing statements in a try/catch, and returning a wrapped result (wrapped differently depending on if the result is an error or success).
As I understand it, engEvalString can only execute a single statement (mabye I'm wrong). If this is the case, since try/catch is inherrently multi-line in MATLAB, I'm not sure how to achieve the desired result.
Ultimately I'd like to have code that matches the following pseudo-code:
engEvalStringSafe(eng, statementString) =
tryStmt = """
try
struct('success', statementString);
catch ex
struct('failure', ex)
end"""
engEvalString(eng, tryStmt)
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Call MATLAB from C 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!