How to use try/catch from the MATLAB engine API
2 ビュー (過去 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!