|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmatlabcontrol.LocalMatlabProxy
public final class LocalMatlabProxy
Allows for calling MATLAB from within MATLAB.
Methods may be called from any thread; however, calling from the Event
Dispatch Thread (EDT) used by AWT and Swing components can be problematic.
When a call is made the calling thread is paused. If the call into MATLAB
makes use of the EDT then MATLAB will hang indefinitely. The EDT is used
extensively by MATLAB when accessing graphical components such as a figure
window, uicontrols or plots.
The way methods are relayed to MATLAB differs depending on whether or not
the methods were invoked on the main MATLAB thread; unexpected behavior may
occur if methods are invoked from multiple threads. Any of the methods that
are relayed to MATLAB may throw exceptions. Exceptions may be thrown if an
internal MATLAB exception occurs.
Method Summary | |
---|---|
static void |
eval(java.lang.String command)
Evaluates a command in MATLAB. |
static void |
exit()
Exits MATLAB. |
static void |
feval(java.lang.String functionName,
java.lang.Object[] args)
Calls a MATLAB function with the name functionName . |
static java.lang.Object |
getVariable(java.lang.String variableName)
Gets the value of the variable named variableName from MATLAB. |
static java.lang.Object |
returningEval(java.lang.String command,
int returnCount)
Evaluates a command in MATLAB. |
static java.lang.Object |
returningFeval(java.lang.String functionName,
java.lang.Object[] args)
Calls a MATLAB function with the name functionName . |
static java.lang.Object |
returningFeval(java.lang.String functionName,
java.lang.Object[] args,
int returnCount)
Calls a MATLAB function with the name functionName . |
static void |
setEchoEval(boolean echo)
Allows for enabling a diagnostic mode that will show in MATLAB each time a Java method that calls into MATLAB is invoked. |
static void |
setVariable(java.lang.String variableName,
java.lang.Object value)
Sets the variable to the given value . |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static void exit() throws MatlabInvocationException
MatlabInvocationException
public static void eval(java.lang.String command) throws MatlabInvocationException
eval(['command'])
.
command
- the command to be evaluated in MATLAB
MatlabInvocationException
returningEval(String, int)
public static java.lang.Object returningEval(java.lang.String command, int returnCount) throws MatlabInvocationException
eval(['command'])
.
returnCount
. If the command you are evaluating is a MATLAB
function you can determine the amount of arguments it returns by using
the nargout
function in the MATLAB Command Window. If it
returns -1 that means the function returns a variable number of
arguments based on what you pass in. In that case, you will need to
manually determine the number of arguments returned. If the number of
arguments returned differs from returnCount
then either
null
or an empty String
will be returned.
command
- the command to be evaluated in MATLABreturnCount
- the number of arguments that will be returned from evaluating the command
MatlabInvocationException
eval(String)
public static void feval(java.lang.String functionName, java.lang.Object[] args) throws MatlabInvocationException
functionName
.
Arguments to the function may be provided as args
, if you
wish to call the function with no arguments pass in null
.
The result of this command will not be returned.
Object
s in the array will be converted into MATLAB
equivalents as appropriate. Importantly, this means that any
String
will be converted to a MATLAB char array, not a
variable name.
functionName
- name of the MATLAB function to callargs
- the arguments to the function, null
if none
MatlabInvocationException
returningFeval(String, Object[], int)
,
returningFeval(String, Object[])
public static java.lang.Object returningFeval(java.lang.String functionName, java.lang.Object[] args) throws MatlabInvocationException
functionName
.
Arguments to the function may be provided as args
, if you
wish to call the function with no arguments pass in null
.
Object
s in the array will be converted into MATLAB
equivalents as appropriate. Importantly, this means that any
String
will be converted to a MATLAB char array, not a
variable name.
returningFeval(String, Object[], int)
and specify
the number of arguments that will be returned.
functionName
- name of the MATLAB function to callargs
- the arguments to the function, null
if none
MatlabInvocationException
feval(String, Object[])
,
returningFeval(String, Object[])
public static java.lang.Object returningFeval(java.lang.String functionName, java.lang.Object[] args, int returnCount) throws MatlabInvocationException
functionName
.
Arguments to the function may be provided as args
, if you
wish to call the function with no arguments pass in null
.
Object
s in the array will be converted into MATLAB
equivalents as appropriate. Importantly, this means that any
String
will be converted to a MATLAB char array, not a
variable name.
returnCount
. You can use the
nargout
function in the MATLAB Command Window to determine
the number of arguments that will be returned. If nargout
returns -1 that means the function returns a variable number of
arguments based on what you pass in. In that case, you will need to
manually determine the number of arguments returned. If the number of
arguments returned differs from returnCount
then either
only some of the items will be returned or null
will be
returned.
functionName
- name of the MATLAB function to callargs
- the arguments to the function, null
if nonereturnCount
- the number of arguments that will be returned from this function
MatlabInvocationException
feval(String, Object[])
,
returningFeval(String, Object[])
public static void setVariable(java.lang.String variableName, java.lang.Object value) throws MatlabInvocationException
value
.
variableName
- value
-
MatlabInvocationException
public static java.lang.Object getVariable(java.lang.String variableName) throws MatlabInvocationException
variableName
-
MatlabInvocationException
public static void setEchoEval(boolean echo) throws MatlabInvocationException
echo
-
MatlabInvocationException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |