MATLAB Engine: engEvalString() with invalid MATLAB command never returns

1 次查看(过去 30 天)
I am using the MATLAB Engine interface in an application that will allow evaluating arbitrary MATLAB inputs (it's a Mathematica/MATLAB interface).
I ran into a problem with engEvalString(): if the input given to it is an incomplete MATLAB command, the function will never return. For example, try
engEvalString(ep, "x = [1 2 3"); /* note no closing ] */
You can test this quickly using the engdemo.c example which is a ready made program that lets the user enter arbitrary MATLAB input and will evaluate it.
Is there a way to work around this? I have no control over the users of my application giving incorrect or incomplete MATLAB input. Getting back an error message would be fine, but the function simply never returns.
Note: I'm on OS X. I'm not sure if the behaviour is the same on Windows.
Additional question: Are there any other interfaces for calling MATLAB from other languages or is MATLAB Engine the only option? I found this unofficial Java solution. Is it also based on the MATLAB Engine internally?
Additional Q2: Is is possible to work around this using MATLAB code? Is there a reliable way to figure out whether a piece of text is 1. syntactically correct and 2. complete MATLAB code, and preferably test for these two things independently?

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Call MATLAB from C 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by