net.tinyos.matlab
Class MatlabControl

java.lang.Object
  extended bynet.tinyos.matlab.MatlabControl

public class MatlabControl
extends java.lang.Object


Nested Class Summary
protected  class MatlabControl.MatlabBlockingFevalCommand
          This class is used to execute a function in matlab and pass paramseters and it also return arguments
protected  class MatlabControl.MatlabEvalCommand
          This class is used to execute a string in Matlab
protected  class MatlabControl.MatlabFevalCommand
          This class is used to execute a function in matlab and pass paramseters
 
Field Summary
(package private)  java.lang.String callbackFunction
           
(package private)  com.mathworks.jmi.Matlab matlab
           
(package private)  java.lang.Object returnVal
           
(package private)  boolean useCb
           
 
Constructor Summary
MatlabControl()
          usually, the default constructor with no arguments is fine.
MatlabControl(boolean useCallback)
           
MatlabControl(boolean useCallback, java.lang.String CallBackFunction)
           
 
Method Summary
 java.lang.Object blockingFeval(java.lang.String Command, java.lang.Object[] args)
          Evaluate a Matlab function that requires arguments and provide return arg.
 void eval(java.lang.String Command)
          Evaluate a string, Matlab script, or Matlab function
 void feval(java.lang.String Command, java.lang.Object[] args)
          Evaluate a Matlab function that requires arguments.
 void setEchoEval(boolean echo)
          Echoing the eval statement is useful if you want to see in matlab each time that a java function tries to execute a matlab command
 void setReturnVal(java.lang.Object val)
          INTERNAL FUNCTIONS AND CLASSES
 void testBlockingFeval(java.lang.String Command, java.lang.Object[] args)
           
 void testEval(java.lang.String Command)
          call these functions from within Matlab itself.
 void testFeval(java.lang.String Command, java.lang.Object[] args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

matlab

com.mathworks.jmi.Matlab matlab

useCb

boolean useCb

returnVal

java.lang.Object returnVal

callbackFunction

java.lang.String callbackFunction
Constructor Detail

MatlabControl

public MatlabControl()
usually, the default constructor with no arguments is fine. Sometimes, a callback function is useful. A callback function is allows the user to pass the command and its arguments to a matlab function, which will figure out the best way to executue it, instead of trying to execute it directly from java. This is often useful for handling/printing errors as well as dealing with native matlab data types, like cell arrays. The cell array is not really converted to a java type, only the handle of the cell array is converted to a java type, so often a matlab callback function is useful for dealing specially with cell arrays, etc.


MatlabControl

public MatlabControl(boolean useCallback)

MatlabControl

public MatlabControl(boolean useCallback,
                     java.lang.String CallBackFunction)
Method Detail

eval

public void eval(java.lang.String Command)
Evaluate a string, Matlab script, or Matlab function


feval

public void feval(java.lang.String Command,
                  java.lang.Object[] args)
Evaluate a Matlab function that requires arguments. Each element of the "args" vector is an argument to the function "Command"


blockingFeval

public java.lang.Object blockingFeval(java.lang.String Command,
                                      java.lang.Object[] args)
                               throws java.lang.InterruptedException
Evaluate a Matlab function that requires arguments and provide return arg. Each element of the "args" vector is an argument to the function "Command"

Throws:
java.lang.InterruptedException

setEchoEval

public void setEchoEval(boolean echo)
Echoing the eval statement is useful if you want to see in matlab each time that a java function tries to execute a matlab command


testEval

public void testEval(java.lang.String Command)
call these functions from within Matlab itself. These are examples of the general execution order: 1. instantiate java object from matlab 2. spawn a new Java thread 3. call matlab functions from new java thread EXAMPLE (from matlab prompt): >> mc=MatlabControl; >> mc.testEval('x = 5') x = 5 > mc.testFeval('help',{'sqrt'}) SQRT Square root. SQRT(X) is the square root of the elements of X. Complex results are produced if X is not positive. See also SQRTM. Overloaded methods help sym/sqrt.m >> mc.testBlockingFeval('sqrt',{x}) 2.2361


testFeval

public void testFeval(java.lang.String Command,
                      java.lang.Object[] args)

testBlockingFeval

public void testBlockingFeval(java.lang.String Command,
                              java.lang.Object[] args)

setReturnVal

public void setReturnVal(java.lang.Object val)
INTERNAL FUNCTIONS AND CLASSES