Package matlabcontrol

Interface MatlabOperations

  • All Known Subinterfaces:
    MatlabProxy.MatlabThreadProxy
    All Known Implementing Classes:
    LinkedOperations, LoggingMatlabProxy, MatlabProxy

    public interface MatlabOperations
    Operations which interact with a session of MATLAB.

    WARNING: This interface is not intended to be implemented by users of matlabcontrol. Methods may be added to this interface, and these additions will not be considered breaking binary compatability.
    Since:
    4.1.0
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void eval​(java.lang.String command)
      Evaluates a command in MATLAB.
      void feval​(java.lang.String functionName, java.lang.Object... args)
      Calls a MATLAB function with the name functionName, returning the result.
      java.lang.Object getVariable​(java.lang.String variableName)
      Gets the value of variableName in 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 name functionName, returning the result.
      void setVariable​(java.lang.String variableName, java.lang.Object value)
      Sets variableName to value in MATLAB, creating the variable if it does not yet exist.
    • Method Detail

      • eval

        void eval​(java.lang.String command)
           throws MatlabInvocationException
        Evaluates a command in MATLAB. This is equivalent to MATLAB's eval('command').
        Parameters:
        command - the command to be evaluated in MATLAB
        Throws:
        MatlabInvocationException
      • returningEval

        java.lang.Object[] returningEval​(java.lang.String command,
                                         int nargout)
                                  throws MatlabInvocationException
        Evaluates a command in MATLAB, returning the result. This is equivalent to MATLAB's eval('command').

        In order for the result of this command to be returned the number of arguments to be returned must be specified by nargout. This is equivalent in MATLAB to the number of variables placed on the left hand side of an expression. For example, in MATLAB the inmem function may be used with either 1, 2, or 3 return values each resulting in a different behavior:
         
         M = inmem;
         [M, X] = inmem;
         [M, X, J] = inmem;
         
         
        The returned Object array will be of length nargout with each return argument placed into the corresponding array position.

        If the command cannot return the number of arguments specified by nargout then an exception will be thrown.
        Parameters:
        command - the command to be evaluated in MATLAB
        nargout - the number of arguments that will be returned from evaluating command
        Returns:
        result of MATLAB command, the length of the array will be nargout
        Throws:
        MatlabInvocationException
      • feval

        void feval​(java.lang.String functionName,
                   java.lang.Object... args)
            throws MatlabInvocationException
        Calls a MATLAB function with the name functionName, returning the result. Arguments to the function may be provided as args, 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 a String will be converted to a MATLAB char array, not a variable name.
        Parameters:
        functionName - the name of the MATLAB function to call
        args - the arguments to the function
        Throws:
        MatlabInvocationException
      • returningFeval

        java.lang.Object[] returningFeval​(java.lang.String functionName,
                                          int nargout,
                                          java.lang.Object... args)
                                   throws MatlabInvocationException
        Calls a MATLAB function with the name functionName, returning the result. Arguments to the function may be provided as args, 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 a String will be converted to a MATLAB char array, 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 by nargout. This is equivalent in MATLAB to the number of variables placed on the left hand side of an expression. For example, in MATLAB the inmem function may be used with either 1, 2, or 3 return values each resulting in a different behavior:
         
         M = inmem;
         [M, X] = inmem;
         [M, X, J] = inmem;
         
         
        The returned Object array will be of length nargout with each return argument placed into the corresponding array position.

        If the function is not capable of returning the number of arguments specified by nargout then an exception will be thrown.
        Parameters:
        functionName - the name of the MATLAB function to call
        nargout - the number of arguments that will be returned by functionName
        args - the arguments to the function
        Returns:
        result of MATLAB function, the length of the array will be nargout
        Throws:
        MatlabInvocationException
      • setVariable

        void setVariable​(java.lang.String variableName,
                         java.lang.Object value)
                  throws MatlabInvocationException
        Sets variableName to value in MATLAB, creating the variable if it does not yet exist.
        Parameters:
        variableName -
        value -
        Throws:
        MatlabInvocationException