Error retrieving MATLAB variable via engGetVariable

I'm trying to retrieve a variable from a MATLAB session embedded in my C++ application, using the Engine API.
A call to engGetVariable(eng, "v") returns NULL, even though a previous call to engEvalString(eng, "who") will show "v" in the output buffer.
Is there anything that may cause this behavior ?
As I'm debugging this I noticed the following:
If I type "v = 'foo'" in an interactive MATLAB session, the generated output starts with "v = ". However, when I call engEvalString(eng, "v = 'foo'") and look at the output, I see it as "ans = ". Could that be related ?
Thanks for any hints !

댓글 수: 3

Stefan
Stefan 2012년 11월 21일
To rephrase the question slightly (as it occurs to me the problem only arises with non-builtin types):
Are there any requirements on the type of objects that may be retrieved via engGetVariable ? Retrieving a builtin array works just fine, but as soon as I wrap it into my custom class, I get NULL back...
Stefan: Could you try contacting MathWorks Tech Support about this? The fact that the issue only occurs with custom classes makes me think this is indeed an API limitation that may not have been documented.
Q1: Can you load the class object from a mat file? (i.e., get it loaded and get the class registered)
Q2: If Q1 works, can you subsequently get the class object from the Engine? (i.e., after the class is registered via the mat load)

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Call MATLAB from C++에 대해 자세히 알아보기

제품

질문:

2012년 11월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by