MATLAB Engine: engEvalString() with invalid MATLAB command never returns
3 次查看(过去 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 个评论
回答(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!