MATLAB: EngEvalString like function you can use from within a MatLab M file

mfile

I was wondering if there was a wrapper or a function like engEvalString that I could call from inside an M file. Currently we are using engEvalString through JMatLink.dll and it’s doing what we want for the most part, but every time we run a test case it takes a long time to run. It opens and closes a new instance of MatLab every time it runs. Normally that wouldn’t be too bad but our copies are on a network so it takes awhile to rune everything.
I want to get away from the dll and do everything with one instance of MatLab open. engEvalString worked almost perfectly for us, but it sets the Inport blocks perfectly. So if there’s a function that does that same thing as engEvalString that I can use from an M file, please let me know. Thanks
P.S. I tried to use engEvalString in the M file but since it takes an Engine pointer it didn’t go over to well. Eval didn't do what I needed it to do either.

Best Answer

I am not familiar with JMatLink, but engEvalString should not open a new instance of MATLAB. It is the engOpen and engClose command that control the starting/closing of the MATLAB instance. All other engine commands issued in between those two calls should use the same instance of MATLAB (assuming you're using the same Engine pointer throughout your code).
Also, the eval command is indeed the MATLAB equivalent of engEvalString. What issues did you run into with it?