Package matlabcontrol.link
Class LinkedOperations
- java.lang.Object
-
- matlabcontrol.link.LinkedOperations
-
- All Implemented Interfaces:
MatlabOperations
public final class LinkedOperations extends java.lang.Object implements MatlabOperations
- Since:
- 4.2.0
-
-
Constructor Summary
Constructors Constructor Description LinkedOperations(MatlabProxy proxy)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voideval(java.lang.String command)Evaluates a command in MATLAB.voidfeval(java.lang.String functionName, java.lang.Object... args)Calls a MATLAB function with the namefunctionName, returning the result.MatlabProxygetDelegateProxy()The proxy used to communicate with MATLAB.java.lang.ObjectgetVariable(java.lang.String variableName)Gets the value ofvariableNamein MATLAB.java.lang.Object[]returningEval(java.lang.String command, int nargout)Evaluates a command in MATLAB, returning the result.java.lang.Object[]returningFeval(java.lang.String functionName, int nargout, java.lang.Object... args)Calls a MATLAB function with the namefunctionName, returning the result.voidsetVariable(java.lang.String variableName, java.lang.Object value)SetsvariableNametovaluein MATLAB, creating the variable if it does not yet exist.
-
-
-
Constructor Detail
-
LinkedOperations
public LinkedOperations(MatlabProxy proxy)
-
-
Method Detail
-
eval
public void eval(java.lang.String command) throws MatlabInvocationExceptionDescription copied from interface:MatlabOperationsEvaluates a command in MATLAB. This is equivalent to MATLAB'seval('command').- Specified by:
evalin interfaceMatlabOperations- Parameters:
command- the command to be evaluated in MATLAB- Throws:
MatlabInvocationException
-
returningEval
public java.lang.Object[] returningEval(java.lang.String command, int nargout) throws MatlabInvocationExceptionDescription copied from interface:MatlabOperationsEvaluates a command in MATLAB, returning the result. This is equivalent to MATLAB'seval('command').
In order for the result of this command to be returned the number of arguments to be returned must be specified bynargout. This is equivalent in MATLAB to the number of variables placed on the left hand side of an expression. For example, in MATLAB theinmemfunction may be used with either 1, 2, or 3 return values each resulting in a different behavior:
The returnedM = inmem; [M, X] = inmem; [M, X, J] = inmem;Objectarray will be of lengthnargoutwith each return argument placed into the corresponding array position.
If the command cannot return the number of arguments specified bynargoutthen an exception will be thrown.- Specified by:
returningEvalin interfaceMatlabOperations- Parameters:
command- the command to be evaluated in MATLABnargout- the number of arguments that will be returned from evaluatingcommand- Returns:
- result of MATLAB command, the length of the array will be
nargout - Throws:
MatlabInvocationException
-
feval
public void feval(java.lang.String functionName, java.lang.Object... args) throws MatlabInvocationExceptionDescription copied from interface:MatlabOperationsCalls a MATLAB function with the namefunctionName, returning the result. Arguments to the function may be provided asargs, but are not required if the function needs no arguments.
The function arguments will be converted into MATLAB equivalents as appropriate. Importantly, this means that aStringwill be converted to a MATLABchararray, not a variable name.- Specified by:
fevalin interfaceMatlabOperations- Parameters:
functionName- the name of the MATLAB function to callargs- the arguments to the function- Throws:
MatlabInvocationException
-
returningFeval
public java.lang.Object[] returningFeval(java.lang.String functionName, int nargout, java.lang.Object... args) throws MatlabInvocationExceptionDescription copied from interface:MatlabOperationsCalls a MATLAB function with the namefunctionName, returning the result. Arguments to the function may be provided asargs, but are not required if the function needs no arguments.
The function arguments will be converted into MATLAB equivalents as appropriate. Importantly, this means that aStringwill be converted to a MATLABchararray, not a variable name.
In order for the result of this function to be returned the number of arguments to be returned must be specified bynargout. This is equivalent in MATLAB to the number of variables placed on the left hand side of an expression. For example, in MATLAB theinmemfunction may be used with either 1, 2, or 3 return values each resulting in a different behavior:
The returnedM = inmem; [M, X] = inmem; [M, X, J] = inmem;Objectarray will be of lengthnargoutwith each return argument placed into the corresponding array position.
If the function is not capable of returning the number of arguments specified bynargoutthen an exception will be thrown.- Specified by:
returningFevalin interfaceMatlabOperations- Parameters:
functionName- the name of the MATLAB function to callnargout- the number of arguments that will be returned byfunctionNameargs- the arguments to the function- Returns:
- result of MATLAB function, the length of the array will be
nargout - Throws:
MatlabInvocationException
-
setVariable
public void setVariable(java.lang.String variableName, java.lang.Object value) throws MatlabInvocationExceptionDescription copied from interface:MatlabOperationsSetsvariableNametovaluein MATLAB, creating the variable if it does not yet exist.- Specified by:
setVariablein interfaceMatlabOperations- Throws:
MatlabInvocationException
-
getVariable
public java.lang.Object getVariable(java.lang.String variableName) throws MatlabInvocationExceptionDescription copied from interface:MatlabOperationsGets the value ofvariableNamein MATLAB.- Specified by:
getVariablein interfaceMatlabOperations- Returns:
- value
- Throws:
MatlabInvocationException
-
getDelegateProxy
public MatlabProxy getDelegateProxy()
The proxy used to communicate with MATLAB.- Returns:
- proxy
-
-