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!