Class JMatLink

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

public class JMatLink
extends Thread

Constructor Index

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

Method Index

 o destroy()
 o engClose()
Close the connection to matlab.
 o engClose(int)
Close a specified connection to an instance of matlab.
 o engEvalString(int, String)
Evaluate an expression in a specified workspace.
 o engEvalString(String)
Evaluate an expression in matlab's workspace.
 o engGetArray(int, String)
Get an array from a specified instance/workspace of matlab.
 o engGetArray(String)
Get an array from matlab's workspace.
 o engGetCharArray(String)
Get an 'char' array (string) from matlab's workspace.
 o engGetScalar(int, String)
Get a scalar value from a specified workspace.
 o engGetScalar(String)
Get a scalar value from matlab's workspace.
 o engGetVector(int, String)
Get an array (1 * n) from a specified workspace.
 o engGetVector(String)
Get an array (1 * n) from matlab's workspace.
 o engOpen()
Open engine.
 o engOpen(String)
Open engine.
 o engOpenSingleUse()
Open engine for single use.
 o engOpenSingleUse(String)
Open engine for single use.
 o engOutputBuffer()
Return the outputs of previous commands from matlab's workspace.
 o engOutputBuffer(int)
Return the outputs of previous commands from a specified instance/ workspace form matlab.
 o engOutputBuffer(int, int)
Return the ouputs of previous commands in matlab's workspace.
 o engPutArray(int, String, double)
Put an array into a specified instance/workspace of matlab.
 o engPutArray(int, String, double[])
Put an array (1 dimensional) into a specified instance/workspace of matlab.
 o engPutArray(int, String, double[][])
Put an array (2 dimensional) into a specified instance/workspace of matlab.
 o engPutArray(String, double)
Put an array into matlab's workspace.
 o engPutArray(String, double[])
Put an array (1 dimensional) into a specified instance/workspace of matlab.
 o engPutArray(String, double[][])
Put an array (2 dimensional) into matlab's workspace.
 o engPutArray(String, int)
Put an array into a specified workspace.
 o kill()
 o run()
 o setDebug(boolean)

Constructors

 o 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();
 

Methods

 o destroy
 public void destroy()
Overrides:
destroy in class Thread
 o kill
 public void kill()
 o 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();
 

 o 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();
 

 o 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);
 

 o 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);
 

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

E.g.:

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

 o 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
 

 o 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();
 

 o 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();
 

 o 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();
 

 o 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();
 

 o 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();
 

 o 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();
 

 o 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();
 

 o 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);
 

 o 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();
 

 o 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();
 

 o 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();
 

 o 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);
 

 o 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();
 

 o 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);
 

 o 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();
 

 o 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);             
 

 o 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();                                                     
 

 o 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();                                                     
 

 o 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();                                                     
 

 o setDebug
 public void setDebug(boolean debugB)
 o run
 public synchronized void run()
Overrides:
run in class Thread