I have been banging my head against the wall with this for days now, and just can't find a solution.
I have a Matlab script that I want to run from a Unity3D project's assets, but I can't make it work properly. The script itself is just fine as it works properly when executed directly in Matlab. The issue is with launching it from Unity. Here's what I have.
String mFile = "Assets/Scripts/MatLab/script.m";
StreamReader reader = new StreamReader(mFile);
Process.Start(
"matlab",
"-nodisplay -nosplash -nodesktop -r \"" + reader.readToEnd() + "\""
);
reader.close();
I know, that's really janky, but it's the only way I've found so far that works even slightly.
The issue comes from the fact that there are double quotes and spaces in the script, which confuses the command line. I've tried escaping those characters, escaping the whole string, everything I could think of.
Before you ask, yes, using MatLab is my only option. I hate it as much as the next guy, but it has some features that I need.
Has anyone gotten this kind of thing to work?
Note: I don't actually have access to the project right now, so any errors in the above code are not the real problem, that's just my best remembrance of it.