This example shows how to call a method in
your own Java® class. The example uses a class file named myclass.class
in
the folder C:\Documents\MATLAB\
, containing a method, package.myclass.mymethod(params)
.
Substitute your own class file name and path, and call the method
with the appropriate parameter list.
This example puts the class file on the dynamic Java class
path, making the class available in the current MATLAB® session
only. MATLAB provides the dynamic path as a convenience for when
you develop your own Java classes. To make the class always available
in MATLAB, use the static class path by editing the javaclasspath.txt
file
in your prefdir
folder.
Add the class to the dynamic Java class path.
javaaddpath('C:\Documents\MATLAB\')
To access the class, you must modify the Java path every time you start MATLAB.
Call the method.
package.myclass.mymethod(params)