edu.ucsb.cs.jicos.services.external.services.matlab
Interface Matlab

All Known Implementing Classes:
MatlabImpl

public interface Matlab

Author:
Peter Cappello

Method Summary
 java.lang.Object evaluate(java.lang.String command, java.lang.String resultName, java.util.Map variableNameValueMap)
          Helper method for above - automatically flushes variables.
 java.lang.Object evaluate(java.lang.String command, java.lang.String resultName, java.util.Map variableNameValueMap, boolean flushVariables)
          Evaluate a matlab string.
 java.lang.Object getVariable(java.lang.String varName)
          Retrieve a variable from the Matlab engine.
 

Method Detail

evaluate

java.lang.Object evaluate(java.lang.String command,
                          java.lang.String resultName,
                          java.util.Map variableNameValueMap,
                          boolean flushVariables)
                          throws MatlabException
Evaluate a matlab string. In order to make this very generic, and to fit the Matlab API, the name of the variable containing the "answer" must be specified. For example:
   
 
 Map data = new HashMap();
 
 

   
 
 data.add( "t", new Integer( 2 ) );
 
 


   
 
 Object result = evaluate( "A = randn[1:5] * t", "A", data );
 
 

will create a value t, assign the value 2 to it, put it into the Matlab engine, and then create a vector of 5 random numbers, and multiply each by 2, then get the answer in the variable A, and return that.

Parameters:
command - The command to be invoked
resultName - The name of the variable containing the result.
variableNameValueMap - All supporting data for the computation.
flushVariables - Delete the variables at the end of the computation.
Returns:
The result of the Matlab computation (most likely a double[][]).
Throws:
MatlabException - On error in the engine.

evaluate

java.lang.Object evaluate(java.lang.String command,
                          java.lang.String resultName,
                          java.util.Map variableNameValueMap)
                          throws MatlabException
Helper method for above - automatically flushes variables.

Parameters:
command - The command to be invoked
resultName - The name of the variable containing the result.
variableNameValueMap - All supporting data for the computation.
Returns:
The result of the Matlab computation (most likely a double[][]).
Throws:
MatlabException - On error in the engine.

getVariable

java.lang.Object getVariable(java.lang.String varName)
                             throws MatlabException
Retrieve a variable from the Matlab engine.

Parameters:
varName - The name of the variable to retrieve.
Returns:
The variable, or null if not available.
Throws:
MatlabException - On error in the engine.


Jicos: http://cs.ucsb.edu/projects/jicos