jmatlink
Class JMatLink

java.lang.Object
  extended byjmatlink.JMatLink

public class JMatLink
extends java.lang.Object


Constructor Summary
JMatLink()
          This is the constructor for the JMatLink library.
 
Method Summary
 void engClose()
          Close the connection to matlab.
 void engClose(long epI)
          Close a specified connection to an instance of matlab.
 void engCloseAll()
          Close all connections to matlab E.g.
 void engEvalString(long epI, java.lang.String evalS)
          Evaluate an expression in a specified workspace.
 void engEvalString(java.lang.String evalS)
          Evaluate an expression in matlab's workspace.
 double[][] engGetArray(long epI, java.lang.String arrayS)
          Get an array from a specified instance/workspace of matlab.
 double[][] engGetArray(java.lang.String arrayS)
          Get an array from matlab's workspace.
 java.lang.String[] engGetCharArray(long epI, java.lang.String arrayS)
          Get an 'char' array (string) from matlab's workspace.
 java.lang.String[] engGetCharArray(java.lang.String arrayS)
          Get an 'char' array (string) from matlab's workspace.
 java.awt.Image engGetFigure(int figure, int dx, int dy)
          Return image of figure from Matlab
 java.awt.Image engGetFigure(long epI, int figure, int dx, int dy)
          Return image of figure from Matlab
 java.lang.String engGetOutputBuffer()
          Return the outputs of previous commands from a specified instance/ workspace form matlab.
 java.lang.String engGetOutputBuffer(long epI)
          Return the ouputs of previous commands in matlab's workspace.
 double engGetScalar(long epI, java.lang.String arrayS)
          Get a scalar value from a specified workspace.
 double engGetScalar(java.lang.String arrayS)
          Get a scalar value from matlab's workspace.
 boolean engGetVisible(long epI)
          return the visibility status of the Matlab window
 void engOpen()
          Open engine.
 void engOpen(java.lang.String startCmdS)
          Open engine.
 long engOpenSingleUse()
          engOpenSingleUse ***************************** Open engine for single use.
 long engOpenSingleUse(java.lang.String startCmdS)
          Open engine for single use.
 int engOutputBuffer()
          Return the outputs of previous commands from matlab's workspace.
 int engOutputBuffer(long epI)
          Return the outputs of previous commands from a specified instance/ workspace form matlab.
 int engOutputBuffer(long epI, int buflenI)
          Return the ouputs of previous commands in matlab's workspace.
 void engPutArray(long epI, java.lang.String arrayS, double valueD)
          Put an array into a specified instance/workspace of matlab.
 void engPutArray(long epI, java.lang.String arrayS, double[] valuesD)
          Put an array (1 dimensional) into a specified instance/workspace of matlab.
 void engPutArray(long epI, java.lang.String arrayS, double[][] valuesDD)
          Put an array (2 dimensional) into a specified instance/workspace of matlab.
 void engPutArray(java.lang.String arrayS, double valueD)
          Put an array into matlab's workspace.
 void engPutArray(java.lang.String arrayS, double[] valuesD)
          Put an array (1 dimensional) into a specified instance/workspace of matlab.
 void engPutArray(java.lang.String arrayS, double[][] valuesDD)
          Put an array (2 dimensional) into matlab's workspace.
 void engPutArray(java.lang.String arrayS, int valueI)
          Put an array into a specified workspace.
 void engSetVisible(long epI, boolean visB)
          Set the visibility of the Matlab window
 java.lang.String getVersion()
          Returns the current version of JMatLink E.g.
 void kill()
          obsolete method
 void setDebug(boolean debugB)
          Switch on or disable debug information printed to standard output.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, 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

getVersion

public java.lang.String getVersion()
Returns the current version of JMatLink

E.g.:

   JMatLink engine = new JMatLink();
   System.out.println("version 0 "+ engine.getVersion());
 

Returns:
VERSION of JMatLink

kill

public void kill()
obsolete method


engOpen

public void 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 void engOpen(java.lang.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 long engOpenSingleUse()
engOpenSingleUse ***************************** Open engine for single use. This command is used to open multiple connections to matlab.

E.g.:

   long 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 long engOpenSingleUse(java.lang.String startCmdS)
Open engine for single use. This command is used to open multiple connections to matlab.

E.g.:

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


engClose

public void engClose()
Close the connection to matlab.

E.g.:

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


engClose

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

E.g.:

  long 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
 


engCloseAll

public void engCloseAll()
Close all connections to matlab

E.g.:

  long a,b;
  JMatLink engine = new JMatLink();
  engine.engOpen();                    // start the general session
  engine.engEvalString("x=sin(5)");
  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.engCloseAll();      // Close all connections to matlab


engSetVisible

public void engSetVisible(long epI,
                          boolean visB)
Set the visibility of the Matlab window

Parameters:
epI - engine handle
visB - desired visiblity true/false

engGetVisible

public boolean engGetVisible(long epI)
return the visibility status of the Matlab window

Parameters:
epI - engine handle
Returns:
visiblity true/false

engEvalString

public void engEvalString(java.lang.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 void engEvalString(long epI,
                          java.lang.String evalS)
Evaluate an expression in a specified workspace.

E.g.:

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


engGetScalar

public double engGetScalar(java.lang.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.engGetScalar("foo");  
  engine.engClose();
 


engGetScalar

public double engGetScalar(long epI,
                           java.lang.String arrayS)
Get a scalar value from a specified workspace.

E.g.:

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


engGetArray

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

E.g.:

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


engGetArray

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

E.g.:

   long 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 java.lang.String[] engGetCharArray(java.lang.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.engGetCharArray("array");
   System.out.println("output = "+ array);
   engine.engClose();
 


engGetCharArray

public java.lang.String[] engGetCharArray(long epI,
                                          java.lang.String arrayS)
Get an 'char' array (string) from matlab's workspace.

E.g.:

   JMatLink engine = new JMatLink();
   long b = engine.engOpenSingleUse(); 
   engine.engEvalString(b, "array = 'hello world';");
   String array = engine.engGetCharArray(b,"array");
   System.out.println("output = "+ array);
   engine.engClose(b);
 


engPutArray

public void engPutArray(java.lang.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 void engPutArray(java.lang.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 void engPutArray(long epI,
                        java.lang.String arrayS,
                        double valueD)
Put an array into a specified instance/workspace of matlab.

E.g.:

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


engPutArray

public void engPutArray(java.lang.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 void engPutArray(long epI,
                        java.lang.String arrayS,
                        double[] valuesD)
Put an array (1 dimensional) into a specified instance/workspace of matlab.

E.g.:

   long 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 void engPutArray(java.lang.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 void engPutArray(long epI,
                        java.lang.String arrayS,
                        double[][] valuesDD)
Put an array (2 dimensional) into a specified instance/workspace of matlab.

E.g.:

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


engOutputBuffer

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

E.g.:

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


engOutputBuffer

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

E.g.:

                                                                    
   String buffer;        
   long b;
   JMatLink engine = new JMatLink();                                      
   b= engine.engOpenSingleUse();                                                   
   engine.engOutputBuffer(b);                               
   engine.engEvalString("surf(peaks), a=555");                                   
   buffer = engine.engGetOutputBuffer(b);                              
   System.out.println("workspace " + buffer);                             
   engine.engClose(b);                                                     
 


engOutputBuffer

public int engOutputBuffer(long 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;
   long b;                                                         
   JMatLink engine = new JMatLink();                                      
   b = engine.engOpen();                                                  
   engine.engEvalString(b, "surf(peaks)");                                   
   buffer = engine.engOutputBuffer(b, 10000);                              
   System.out.println("workspace " + buffer);                             
   engine.engClose(b);                                                     
 


engGetOutputBuffer

public java.lang.String engGetOutputBuffer()
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.engGetOutputBuffer();                              
   System.out.println("workspace " + buffer);                             
   engine.engClose();                                                     
 


engGetOutputBuffer

public java.lang.String engGetOutputBuffer(long epI)
Return the ouputs of previous commands in matlab's workspace. Right now the parameter buflen is not supported.

E.g.:

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


engGetFigure

public java.awt.Image engGetFigure(long epI,
                                   int figure,
                                   int dx,
                                   int dy)
Return image of figure from Matlab

Parameters:
epI - handle to matlab engine
figure - handle to matlab figure n
dx - columns of image in pixels
dy - rows of image in pixels
Returns:
image of the requested figure window from matlab

engGetFigure

public java.awt.Image engGetFigure(int figure,
                                   int dx,
                                   int dy)
Return image of figure from Matlab

Parameters:
figure - handle to matlab figure n
dx - columns of image in pixels
dy - rows of image in pixels
Returns:
image of the requested figure window from matlab

setDebug

public void setDebug(boolean debugB)
Switch on or disable debug information printed to standard output.

Default setting is debug info disabled.

E.g.:

   JMatLink engine = new JMatLink();
   engine.engOpenSingleUse();  
   engine.setDebug(true);
   engine.engEvalString("a=ones(10,5);");
   engine.engClose();