|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectmatlabcontrol.MatlabProxy
public abstract class MatlabProxy
Communicates with a running MATLAB session. This class cannot be instantiated, it may be created with a
MatlabProxyFactory. Interaction with MATLAB occurs as if calling eval and feval in the
MATLAB Command Window.
double[]. For complex numbers, only the real component is converted. MATLAB
logicals whether a singular value or an array/matrix (of any dimension) are always converted into a
one-dimensional Java boolean[]. MATLAB arrays are stored in a linear manner, which has been
documented by The MathWorks. It is in
this linear manner that MATLAB arrays are returned to Java. (Sparse matrices are stored differently and are not sent
to Java in an easy to use manner.)
char singular values are returned as a Java String. One-dimensional MATLAB char
arrays are returned as a Java String. Two-dimensional MATLAB char arrays are returned as a Java
String[] with each row of the MATLAB array becoming a Java String. MATLAB char arrays of
more than two dimensions have an inconsistent conversion to a Java type, although all observed conversions are
either a Java String or an array of Strings.
cell arrays and struct arrays are converted to a Java Object[], often with arrays
inside of them.
function_handles and all non-built-in classes (such as the Map class or user defined classes)
are converted to an instance of com.mathworks.jmi.types.MLArrayRef that is not Serializable which
prevents it from being transferred to a Java application running outside MATLAB (more information on this can be
found in the exception section below).
Object or Object[] which results in the Java primitives becoming their
auto-boxed class equivalent. (For example int becomes Integer.) Java primitive arrays, such as
int[] are Objects and can therefore be sent to the MATLAB environment. They are converted as follows:
| Java Type | MATLAB Type |
|---|---|
boolean[] | logical array |
char[] | not supported* |
byte[] | int8 array |
short[] | int16 array |
int[] | int32 array |
long[] | not supported* |
float[] | single array |
double[] | double array |
NumbersNumber, which includes all of the auto-boxed versions of Java primitive numeric types, become
MATLAB doubles.
BooleansBooleans are converted to MATLAB logicals.
CharactersCharacters are converted to MATLAB chars.
StringsStrings are converted to MATLAB char arrays.
cell arrays. The contents of the array are converted
according to these same rules. Note that Java's multidimensional arrays are not an exception to this rule. For
instance a double[][] is an array of double[]s and so MATLAB will create a cell array of MATLAB
double arrays.
Remote
will act as if they are not copies. This is because matlabcontrol communicates with MATLAB's Java Virtual Machine
using
Remote Method Invocation.)
MatlabProxyLogger exists to record what is being returned from MATLAB.
The MatlabTypeConverter can convert between complicated Java and MATLAB types.
Currently only MATLAB numeric arrays are supported.
MatlabInvocationExceptions. They will be thrown if:
disconnect().long[] to MATLAB. Due to the undocumented nature of this interface, it is not entirely known what
actions may result in an exception.Serializable or
Remote.1 Java primitives and arrays behave as if they were Serializable.SecurityManager has been installed.2SecurityManager has been set. PermissiveSecurityManager exists to provide an easy
way to set a security manager without further restricting permissions. Please consult
PermissiveSecurityManager's documentation for more information.
MatlabProxyFactory are able to load all classes defined in your
application's class path as specified by the java.class.path property. Some frameworks load classes without
placing them on the class path, in that case matlabcontrol will not know about them and cannot tell MATLAB how to
load them.
invokeAndWait(...).
disconnect().
MatlabProxyFactory.getProxy(),
MatlabProxyFactory.requestProxy(matlabcontrol.MatlabProxyFactory.RequestCallback)| Nested Class Summary | |
|---|---|
static interface |
MatlabProxy.DisconnectionListener
Listens for a proxy's disconnection from MATLAB. |
static interface |
MatlabProxy.Identifier
Uniquely identifies a proxy. |
static interface |
MatlabProxy.MatlabThreadCallable<T>
Uninterrupted block of computation performed in MATLAB. |
static interface |
MatlabProxy.MatlabThreadProxy
Operates on MATLAB's main thread without interruption. |
| Method Summary | ||
|---|---|---|
void |
addDisconnectionListener(MatlabProxy.DisconnectionListener listener)
Adds a disconnection listener that will be notified when this proxy becomes disconnected from MATLAB. |
|
abstract boolean |
disconnect()
Disconnects the proxy from MATLAB. |
|
abstract void |
exit()
Exits MATLAB. |
|
MatlabProxy.Identifier |
getIdentifier()
Returns the unique identifier for this proxy. |
|
abstract
|
invokeAndWait(MatlabProxy.MatlabThreadCallable<T> callable)
Runs the callable on MATLAB's main thread and waits for it to return its result. |
|
abstract boolean |
isConnected()
Whether this proxy is connected to MATLAB. |
|
boolean |
isExistingSession()
Whether this proxy is connected to a session of MATLAB that was running previous to the request to create this proxy. |
|
abstract boolean |
isRunningInsideMatlab()
Whether this proxy is running inside of MATLAB. |
|
void |
removeDisconnectionListener(MatlabProxy.DisconnectionListener listener)
Removes a disconnection listener. |
|
java.lang.String |
toString()
Returns a brief description of this proxy. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface matlabcontrol.MatlabOperations |
|---|
eval, feval, getVariable, returningEval, returningFeval, setVariable |
| Method Detail |
|---|
public MatlabProxy.Identifier getIdentifier()
public boolean isExistingSession()
public java.lang.String toString()
toString in class java.lang.Objectpublic void addDisconnectionListener(MatlabProxy.DisconnectionListener listener)
listener - public void removeDisconnectionListener(MatlabProxy.DisconnectionListener listener)
listener - public abstract boolean isRunningInsideMatlab()
public abstract boolean isConnected()
false are if the proxy has been disconnected via
disconnect() or MATLAB has been closed (when running outside MATLAB).
disconnect(),
exit()public abstract boolean disconnect()
true if the proxy is now disconnected,
false otherwise.
exit(),
isConnected()
public abstract void exit()
throws MatlabInvocationException
eval or feval command will cause MATLAB to
hang indefinitely.
MatlabInvocationExceptiondisconnect(),
isConnected()
public abstract <T> T invokeAndWait(MatlabProxy.MatlabThreadCallable<T> callable)
throws MatlabInvocationException
callable on MATLAB's main thread and waits for it to return its result. This method allows for
uninterrupted access to MATLAB's main thread between two or more interactions with MATLAB.
callable must be Serializable; it may not be
Remote.
T - callable -
MatlabInvocationException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||