The MATLAB® engine API for Java® ships with example
code that you can use to test your environment and to become familiar
with the use of the engine API. The Java source code is located
in the
folder,
where matlabroot
/extern/examples/engines/java
is
the path returned by the MATLAB matlabroot
matlabroot
command.
The folder contains these files:
EngineGUIDemo.java
— A Swing-based
user interface that accepts an input number and uses MATLAB to
calculate the factorial of the number.
EngineConsoleDemo.java
—
A Java program that uses MATLAB logical indexing and mathematical
functions to operate on a numeric matrix.
README
— A text file that
describes how to build and run the examples.
To build these examples, first copy the files to a writable
folder on your path. You can use the MATLAB copyfile
function for this purpose:
copyfile(fullfile(matlabroot,'extern','examples','engines','java','EngineGUIDemo.java'),'DestinationFolder') copyfile(fullfile(matlabroot,'extern','examples','engines','java','EngineConsoleDemo.java'),'DestinationFolder')
Follow the instructions in the README
file
to compile and run the examples.