How to use try/catch from the MATLAB engine API

2 ビュー (過去 30 日間)
Brandon Barker
Brandon Barker 2020 年 5 月 28 日
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 件)

カテゴリ

Help Center および File ExchangeCall MATLAB from C についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by