Should I instantiate MatlabControl from withing Matlab or Java? <p>It is not obvious from here <a href="http://www.cs.virginia.edu/~whitehouse/matlab/JavaMatlab.html" rel="nofollow">http://www.cs.virginia.edu/~whitehouse/matlab/JavaMatlab.html</a>, how to use <code>MatlabControl</code> class.</p> <p>On one hand it is given an example:</p> <blockquote> <p>First, instantiate a MatlabControl object</p> <pre><code> MatlabControl mc = new MatlabControl(); </code></pre> </blockquote> <p>On the other hand it is said </p> <blockquote> <p>Snag 1: MatlabControl objects must be instantiated from within your Matlab session! (or by other java objects that were instantiated by your matlab session). This is because Matlab runs its own JVM, and you need to run MatlabControl in the same JVM that matlab is using. (this is why you need to make sure that MatlabControl is in your matlab classpath.) More specifically, if your program is defined in "mypackage/MyClass.java", you need to type</p> <p>mypackage.MyClass.main({'param1','param2',...})</p> </blockquote> <p>What is correct? Where to execute </p> <pre><code>MatlabControl mc = new MatlabControl(); </code></pre> <p>?</p> <p>In my java code?</p> <p>Or at matlab command prompt?</p>