HEADER


Class JMatLink

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--JMatLink

public class JMatLink
extends Thread


Fields inherited from class java.lang.Thread
MIN_PRIORITY, NORM_PRIORITY, MAX_PRIORITY

Constructor Summary
JMatLink()
          This is the constructor for the JMatLink library.

Method Summary
 voiddestroy()
           
 synchronized voidengClose()
          Close the connection to matlab.
 synchronized voidengClose(int epI)
          Close a specified connection to an instance of matlab.
 synchronized voidengEvalString(String evalS)
          Evaluate an expression in matlab's workspace.
 synchronized voidengEvalString(int epI, String evalS)
          Evaluate an expression in a specified workspace.
 synchronized double[][]engGetArray(String arrayS)
          Get an array from matlab's workspace.
 synchronized double[][]engGetArray(int epI, String arrayS)
          Get an array from a specified instance/workspace of matlab.
 synchronized String[]engGetCharArray(String arrayS)
          Get an 'char' array (string) from matlab's workspace.
 synchronized doubleengGetScalar(String arrayS)
          Get a scalar value from matlab's workspace.
 synchronized doubleengGetScalar(int epI, String arrayS)
          Get a scalar value from a specified workspace.
 synchronized double[]engGetVector(String arrayS)
          Get an array (1 * n) from matlab's workspace.
 synchronized double[]engGetVector(int epI, String arrayS)
          Get an array (1 * n) from a specified workspace.
 synchronized intengOpen()
          Open engine.
 synchronized intengOpen(String startCmdS)
          Open engine.
 synchronized intengOpenSingleUse()
          Open engine for single use.
 synchronized intengOpenSingleUse(String startCmdS)
          Open engine for single use.
 synchronized StringengOutputBuffer()
          Return the outputs of previous commands from matlab's workspace.
 synchronized StringengOutputBuffer(int epI)
          Return the outputs of previous commands from a specified instance/ workspace form matlab.
 synchronized StringengOutputBuffer(int epI, int buflenI)
          Return the ouputs of previous commands in matlab's workspace.
 synchronized voidengPutArray(String arrayS, int valueI)
          Put an array into a specified workspace.
 synchronized voidengPutArray(String arrayS, double valueD)
          Put an array into matlab's workspace.
 synchronized voidengPutArray(int epI, String arrayS, double valueD)
          Put an array into a specified instance/workspace of matlab.
 synchronized voidengPutArray(String arrayS, double[] valuesD)
          Put an array (1 dimensional) into a specified instance/workspace of matlab.
 synchronized voidengPutArray(int epI, String arrayS, double[] valuesD)
          Put an array (1 dimensional) into a specified instance/workspace of matlab.
 synchronized voidengPutArray(String arrayS, double[][] valuesDD)
          Put an array (2 dimensional) into matlab's workspace.
 synchronized voidengPutArray(int epI, String arrayS, double[][] valuesDD)
          Put an array (2 dimensional) into a specified instance/workspace of matlab.
 static StringgetErrorMessage()
           
 voidkill()
           
 static voidresetErrorMessage()
           
 synchronized voidrun()
           
 voidsetDebug(boolean debugB)
           

Methods inherited from class java.lang.Thread
currentThread, yield, sleep, sleep, start, stop, stop, interrupt, interrupted, isInterrupted, isAlive, suspend, resume, setPriority, getPriority, setName, getName, getThreadGroup, activeCount, enumerate, countStackFrames, join, join, join, dumpStack, setDaemon, isDaemon, checkAccess, toString, getContextClassLoader, setContextClassLoader

Methods inherited from class java.lang.Object
getClass, hashCode, equals, notify, notifyAll, wait, wait, wait

Constructor Detail

JMatLink

public JMatLink()
This is the constructor for the JMatLink library.

E.g.:

JMatLink engine = new JMatLink();
engine.engOpen();
engine.engEvalString("surf(peaks)");
engine.engClose();
Method Detail

destroy

public void destroy()

engClose

public synchronized void engClose()
Close the connection to matlab.

E.g.:

JMatLink engine = new JMatLink();
engine.engOpen();
engine.engEvalString("surf(peaks)");
engine.engClose();

engClose

public synchronized void engClose(int epI)
Close a specified connection to an instance of matlab.

E.g.:

int a,b;
JMatLink engine = new JMatLink();
a = engine.engOpenSingleUse();       // start first  matlab session
b = engine.engOpenSingleUse();       // start second matlab session
engine.engEvalString(b, "surf(peaks)");
engine.engEvalString(a, "array = randn(23)");
engine.engClose(a);      // Close the first  connection to matlab
engine.engClose(b);      // Close the second connection to matlab

engEvalString

public synchronized void engEvalString(String evalS)
Evaluate an expression in matlab's workspace. E.g.:
JMatLink engine = new JMatLink();
engine.engOpen();
engine.engEvalString("surf(peaks)");
engine.engClose();

engEvalString

public synchronized void engEvalString(int epI, String evalS)
Evaluate an expression in a specified workspace.

E.g.:

int a,b;
JMatLink engine = new JMatLink();
a = engine.engOpenSingleUse();
engine.engEvalString(a, "surf(peaks)");
engine.engClose();

engGetArray

public synchronized double[][] engGetArray(String arrayS)
Get an array from matlab's workspace.

E.g.:

int b;
double[][] array;
JMatLink engine = new JMatLink();
engine.engOpen();
engine.engEvalString("array = randn(10);");
array = engine.engGetArray("array");
engine.engClose();

engGetArray

public synchronized double[][] engGetArray(int epI, String arrayS)
Get an array from a specified instance/workspace of matlab.

E.g.:

int b;
double[][] array;
JMatLink engine = new JMatLink();
b = engine.engOpenSingleUse();
engine.engEvalString(b, "array = randn(10);");
array = engine.engGetArray(b, "array");
engine.engClose(b);

engGetCharArray

public synchronized String[] engGetCharArray(String arrayS)
Get an 'char' array (string) from matlab's workspace.

E.g.:

String array;
JMatLink engine = new JMatLink();
engine.engOpen();
engine.engEvalString("array = 'hello world';");
array = engine.engCharArray("array");
System.out.println("output = "+ array);
engine.engClose();

engGetScalar

public synchronized double engGetScalar(String arrayS)
Get a scalar value from matlab's workspace.

E.g.:

double a;
JMatLink engine = new JMatLink();
engine.engOpen();
engine.engEvalString("foo = sin( 3 )");
a = engine.engGetScalarValue("foo");
engine.engClose();

engGetScalar

public synchronized double engGetScalar(int epI, String arrayS)
Get a scalar value from a specified workspace.

E.g.:

double a;
int b;
JMatLink engine = new JMatLink();
b = engine.engOpenSigleUse();
engine.engEvalString(b, "foo = sin( 3 )");
a = engine.engGetScalarValue(b, "foo");
engine.engClose();

engGetVector

public synchronized double[] engGetVector(String arrayS)
Get an array (1 * n) from matlab's workspace.

E.g.:

double[] array;
JMatLink engine = new JMatLink();
engine.engOpen();
engine.engEvalString("array = randn(10,1);");
array = engine.engGetVector("array");
engine.engClose();

engGetVector

public synchronized double[] engGetVector(int epI, String arrayS)
Get an array (1 * n) from a specified workspace.

E.g.:

int b;
double[] array;
JMatLink engine = new JMatLink();
b = engine.engOpenSingleUse();
engine.engEvalString(b, "array = randn(10,1);");
array = engine.engGetVector(b, "array");
engine.engClose();

engOpen

public synchronized int engOpen()
Open engine. This command is used to open a single connection to matlab.

E.g.:

JMatLink engine = new JMatLink();
engine.engOpen();
engine.engEvalString("surf(peaks)");
engine.engClose();

engOpen

public synchronized int engOpen(String startCmdS)
Open engine. This command is used to open a single connection to matlab.

This command is only useful on unix systems. On windows the optional parameter must be NULL.

E.g.:

JMatLink engine = new JMatLink();
engine.engOpen("commands to start matlab");
engine.engEvalString("surf(peaks)");
engine.engClose();

engOpenSingleUse

public synchronized int engOpenSingleUse()
Open engine for single use. This command is used to open multiple connections to matlab.

E.g.:

int a,b;
JMatLink engine = new JMatLink();
a = engine.engOpenSingleUse();   // start first matlab session
b = engine.engOpenSingleUse();   // start second matlab session
engine.engEvalString(a, "surf(peaks)");
engine.engEvalString(b, "foo=ones(10,0)");
engine.engClose(a);
engine.engClose(b);

engOpenSingleUse

public synchronized int engOpenSingleUse(String startCmdS)
Open engine for single use. This command is used to open multiple connections to matlab.

E.g.:

int a,b;
JMatLink engine = new JMatLink();
a = engine.engOpenSingleUse("start matlab");   // start first matlab session
b = engine.engOpenSingleUse("start matlab");   // start second matlab session
engine.engEvalString(a, "surf(peaks)");
engine.engEvalString(b, "foo=ones(10,0)");
engine.engClose(a);
engine.engClose(b);

engOutputBuffer

public synchronized String engOutputBuffer()
Return the outputs of previous commands from matlab's workspace.

E.g.:

String buffer;
JMatLink engine = new JMatLink();
engine.engOpen();
engine.engEvalString("surf(peaks)");
buffer = engine.engOutputBuffer();
System.out.println("workspace " + buffer);
engine.engClose();

engOutputBuffer

public synchronized String engOutputBuffer(int epI)
Return the outputs of previous commands from a specified instance/ workspace form matlab.

E.g.:

String buffer;
JMatLink engine = new JMatLink();
engine.engOpen();
engine.engEvalString("surf(peaks)");
buffer = engine.engOutputBuffer();
System.out.println("workspace " + buffer);
engine.engClose();

engOutputBuffer

public synchronized String engOutputBuffer(int epI, int buflenI)
Return the ouputs of previous commands in matlab's workspace. Right now the parameter buflen is not supported.

E.g.:

String buffer;
JMatLink engine = new JMatLink();
engine.engOpen();
engine.engEvalString("surf(peaks)");
buffer = engine.engOutputBuffer();
System.out.println("workspace " + buffer);
engine.engClose();

engPutArray

public synchronized void engPutArray(String arrayS, int valueI)
Put an array into a specified workspace.

E.g.:

int array = 1;
JMatLink engine = new JMatLink();
engine.engOpen();
engine.engPutArray("array", array);
engine.engClose();

engPutArray

public synchronized void engPutArray(String arrayS, double valueD)
Put an array into matlab's workspace.

E.g.:

double array = 1;
JMatLink engine = new JMatLink();
engine.engOpen();
engine.engPutArray("array", array);
engine.engClose();

engPutArray

public synchronized void engPutArray(int epI, String arrayS, double valueD)
Put an array into a specified instance/workspace of matlab.

E.g.:

int b;
double array = 1;
JMatLink engine = new JMatLink();
b = engine.engOpenSingleUse();
engine.engPutArray(b, "array", array);
engine.engClose(b);

engPutArray

public synchronized void engPutArray(String arrayS, double[] valuesD)
Put an array (1 dimensional) into a specified instance/workspace of matlab.

E.g.:

double[] array = {1.0 , 2.0 , 3.0};
JMatLink engine = new JMatLink();
engine.engOpen();
engine.engPutArray("array", array);
engine.engClose();

engPutArray

public synchronized void engPutArray(int epI, String arrayS, double[] valuesD)
Put an array (1 dimensional) into a specified instance/workspace of matlab.

E.g.:

int b;
double[] array = {1.0 , 2.0 , 3.0};
JMatLink engine = new JMatLink();
b = engine.engOpenSingleUse();
engine.engPutArray(b, "array", array);
engine.engClose(b);

engPutArray

public synchronized void engPutArray(String arrayS, double[][] valuesDD)
Put an array (2 dimensional) into matlab's workspace.

E.g.:

double[][] array={{1.0 , 2.0 , 3.0},
{4.0 , 5.0 , 6.0}};
JMatLink engine = new JMatLink();
engine.engOpenSingleUse();
engine.engPutArray("array", array);
engine.engClose();

engPutArray

public synchronized void engPutArray(int epI, String arrayS, double[][] valuesDD)
Put an array (2 dimensional) into a specified instance/workspace of matlab.

E.g.:

int b;
double[][] array={{1.0 , 2.0 , 3.0},
{4.0 , 5.0 , 6.0}};
JMatLink engine = new JMatLink();
b = engine.engOpenSingleUse();
engine.engPutArray(b, "array", array);
engine.engClose(b);

getErrorMessage

public static String getErrorMessage()

kill

public void kill()

resetErrorMessage

public static void resetErrorMessage()

run

public synchronized void run()

setDebug

public void setDebug(boolean debugB)

Association Links

to Class java.lang.String

to Class java.lang.String

to Class java.lang.String

to Class java.lang.String

to Class java.lang.String

to Class java.lang.Thread

to Class java.lang.String


FOOTER

BOTTOM