<h3>MATLAB Engine for Java</h3>

<p>This library  uses the C API of the MATLAB Engine to:</p>
<ul>
<li>put variables from Java to Matlab</li>
<li>evaluate Matlab commands</li>
<li>get results from Matlab to Java</li>
</ul>

<p><a href="http://mat4j.sourceforge.net/">http://mat4j.sourceforge.net/</a></p>

<h4>Simple Example</h4>

<p>This Java code:</p>
<pre><code class="language-java">MatlabEngine matlabEngine = new MatlabEngine();
matlabEngine.open(null);

matlabEngine.eval("x = sin([0:pi/2:2*pi])");
System.out.println(matlabEngine.getOutput());

DoubleMatrix doubleMatrix = (DoubleMatrix)matlabEngine.getVariable("x");
System.out.println("doubleMatrix = " + doubleMatrix.toString());

matlabEngine.close();
</code></pre>

<p>Prints the following to standard output:</p>
<pre><samp>x =

         0    1.0000    0.0000   -1.0000   -0.0000


doubleMatrix = [[0.0, 1.0, 1.2246467991473532E-16, -1.0, -2.4492935982947064E-16]]
</samp></pre>

<p>Please have a look at the unit tests in the src package for more examples.</p>


<h4>Test Console</h4>

<p><code>mat4j.sh</code> / <code>mat4j.bat</code> is a Java console application for evaluating Matlab commands.</p>

<p>
Predefined Java commands:<br />
<code>exit</code> / <code>quit</code> - Quits this application<br />
<code>get varname</code> - Converts Matlab variables to Java objects and calls toString()<br />
<code>getImage hFigureVarName</code> - Grabs a Matlab figure to a Java AWT Image
</p>


<p>Example:</p>
<pre><samp>&gt;&gt; x = [1:5];
&gt;&gt; get x
[[1.0, 2.0, 3.0, 4.0, 5.0]]
&gt;&gt; x

x =

     1     2     3     4     5

</samp></pre>


<h4>Disclaimer</h4>

<p>
MATLAB is a registered trademark of The MathWorks, Inc.
</p>
<p>
Java and all of Oracle, Inc.'s Java-based trademarks and logos are trademarks<br />
or registered trademarks of Oracle, Inc., in the US and/or other countries.
</p>